Google Cloud Firestore console reading of all documents and charges

前端 未结 3 537
太阳男子
太阳男子 2021-01-13 16:19

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

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-13 16:51

    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 .

提交回复
热议问题