I'm building an e-commerce app with Next JS 13 and firebase. and there is a page to manage a post. this page only displays post of the user. currently i have 4 documents in my post collection. and with the credential i'm currently logged in has no post. yet the doc read for this is counting as 6 doc reads. i'm using NextAuth with firebase as an adapter. and i'm checking the session status with Next Auth so maybe if that has an effect on the read.
this is what i've done in my code.
export default function ManageListing(){
const { data: session, status } = useSession();
const getData = async () => {
if (status == "authenticated") {
const constraints = [];
constraints.push(where("posetedBy", "==", session?.user.email));
constraints.push(limit(10));
const livings = collection(db, "posts");
let q = query(livings, ...constraints);
const qSnapshot = await getDocs(q);
const dataQ = qSnapshot.docs.map((doc) => ({
...doc.data(),
id: doc.id,
}));
setDatas(dataQ);
}
};
useEffect(() => {
setLoader(true);
setTimeout(() => {
console.log(datas.length);
if (filled == false) {
getData();
}
}, 1000);
}, [status == "authenticated"]);
}
as i mentioned above with the account i'm logged in, i've not posted anything so the return should be empty. but Firebase is considering it as a read. even if it counts it as a read it should've been the amount of docs that exists in the collection which is 4. but the read i'm getting from firebase console is sometimes it's 6 or 4 or 8 or 23 or 12... why is this happening?
NB. my firebase console is not open, only the usage section and it has no effect on the read.