async booleanFunction(email: string, bool: boolean){
console.log('here')
const db = getFirestore();
const q = query(collection(db, "users"), where("email", "==", email), limit(1));
const querySnapshot = await getDocs(q);
await updateDoc(querySnapshot, {
disabled: !bool
});
}
Here is my function which takes in email and a bool value(this needs to be updated), I don't have the _id that firestore provides so I need some alternate to query data and update it
This the the error that shows up
Argument of type 'QuerySnapshot<DocumentData>' is not assignable to parameter of type 'DocumentReference<{ disabled: boolean; }>'.
Type 'QuerySnapshot' is missing the following properties from type 'DocumentReference<{ disabled: boolean; }>': converter, type, firestore, id, and 3 more.
The problem is here:
await updateDoc(querySnapshot, {
disabled: !bool
});
You're trying to call updateDoc on a QuerySnapshot, which isn't possible and never has been possible on v8 either.
You can only call updateDoc on a DocumentReference. So you will have to loop over the documents in the QuerySnapshot and call updateDoc on each of them:
await Promise.all(() =>
querySnapshot.docs.map((doc) =>
updateDoc(doc.ref, { disabled: !bool })
)
)