I want to query a firestore database for document id. Currently I have the following code:
db.collection(\'books\').where(\'id\', \'==\', \'fK3ddutEpD2qQqRMX
You can use the __name__
key word to use your document ID in a query.
Instead of this db.collection('books').doc('fK3ddutEpD2qQqRMXNW5').get()
you can write
db.collection('books').where('__name__', '==' ,'fK3ddutEpD2qQqRMXNW5').get()
.
In this case you should get an array of length 1
back.
The firebase docs mention this feature in the rules documentation. https://firebase.google.com/docs/reference/rules/rules.firestore.Resource