Skip to content

Cannot query by document id #153

@LucasAschenbach

Description

@LucasAschenbach

Apparently, at the moment there is no functioning python client which can filter query results by document id. To my understanding, this should work by simply putting __name__ as field value in any where/order clause like in this example:

from google.cloud import firestore_v1

db = firestore_v1.Client()

# query user data
query = db.collection('users').where(firestore_v1.field_path.FieldPath.document_id(), '==', '...').stream()
dicts = []
for doc in query:
  dicts.append(doc.to_dict())
 
print(dicts)

However, this code will throw the following exception:

__key__ filter value must be a Key

Metadata

Metadata

Labels

api: firestoreIssues related to the googleapis/python-firestore API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions