Query firestore database for document id

后端 未结 6 665
梦毁少年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条回答
  •  -上瘾入骨i
    2020-12-01 04:03

    I am a bit late, but there is actually a way to do this

    db.collection('books').where(firebase.firestore.FieldPath.documentId(), '==', 'fK3ddutEpD2qQqRMXNW5').get()
    

    This might be useful when you're dealing with firebase security rules and only want to query for the records you're allowed to access.

提交回复
热议问题