Query firestore database for document id

后端 未结 6 663
梦毁少年i
梦毁少年i 2020-12-01 03:09

I want to query a firestore database for document id. Currently I have the following code:

db.collection(\'books\').where(\'id\', \'==\', \'fK3ddutEpD2qQqRMX         


        
6条回答
  •  离开以前
    2020-12-01 04:09

    You can get a document by its id following this pattern:

    firebase
      .firestore()
      .collection("Your collection")
      .doc("documentId")
      .get()
      .then((docRef) => { console.log(docRef.data()) })
      .catch((error) => { })
    

提交回复
热议问题