Sorry I'm still new to this, but I'm trying to check whether a specific field (docName) value already exists in a nested collection to perform as a condition. I'm new to v9 and I'm slowly working my way around it, but I've looked all over and I'm still unable to get the appropriate solution.
Ref:
'teachers/${uid}/contracts/autoDocID'
What I have tried
const Contract = async (data) => {
const q = query(collection(db, "teachers", data.uid, "contracts"), where("docName", "==", `${data.docName}`));
const condition = await getDocs(q).exists;
if(!condition){
//adding new doc
}
}
Via Active questions tagged javascript - Stack Overflow https://ift.tt/2f6ihV4
Comments
Post a Comment