I am new to Firestore so I have a Profiles and Users collections. In the Cloud Firestore Console when I click on Database > Firestore > Data tab > Profiles or > Users the co
I just have a similar Question like and I find it redundant to post it as a Question so I'm posting it as asnswer,sorry for that,
Question:
this.db.collection(this.collectionName.usersCollection)
.doc(currentUserId).collection(this.collectionName.friendsCollection)
.where("friendID","==",id)
.get().then(snapshot =>{
if(snapshot.empty)
{
this.db.collection(this.collectionName.chatsCollection).add({
user1 : currentUserId,
user2 : id
}).then(docRef =>{
docId = docRef.id;
this.db.collection(this.collectionName.usersCollection)
.doc(currentUserId)
.collection(this.collectionName.friendsCollection).doc(docId)
.set({
friendID: id,
})
this.db.collection(this.collectionName.usersCollection).doc(id)
.collection(this.collectionName.friendsCollection).doc(docId)
.set({
friendID:currentUserId,
})
resolve(docRef.id);
})
}
else{
snapshot.forEach(document =>{
// console.log("friend id",document.data().friendID, " docid: ",document.data().docId);
resolve(document.id);
})
}
})
so here I'm writing and reading the docId ,so will it affect the counts? I cannot have a check properly because with this many other operations are happening. Thanks .