Query firestore database for document id

后端 未结 6 687
梦毁少年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:08

    From Firestore docs for Get a document.

    var docRef = db.collection("cities").doc("SF");
    
    docRef.get().then(function(doc) {
        if (doc.exists) {
            console.log("Document data:", doc.data());
        } else {
            // doc.data() will be undefined in this case
            console.log("No such document!");
        }
    }).catch(function(error) {
        console.log("Error getting document:", error);
    });
    

提交回复
热议问题