I was practicing firebase firestore and I am trying to update the data I retrieved based on a condition and I am getting this error
FirebaseError: Expected type 'rc', but it was: a custom oc object
if (updateMerge === "update") {
const q = query(
collection(db, "contacts"),
where("fname", "==", firstName, "lname", "==", lastName)
);
const querySnapshot = await getDocs(q);
querySnapshot.forEach((doc) => {
console.log(doc.id, " => ", doc.data());
const payload = { phone: phone };
setDoc(q, payload);
});
}
I am doing a contact app I can see the retrieved data on the console and I want to change the phone number if a user already has an account, so the payload changes the phone(from firestore document field):phone(phone state). so I have done some practice with setDoc but I usually use "collectionRef" but not with a query, if I can see the console most probably the error would be here
setDoc(q, payload);
Thanks In advance