If I want to query firebase documents under specific collection, how can I skip query some of document ID?
What I expected was
from firebase_admin import firestore
db = firestore.client()
skip_id = ["3zbBeHVvMY2aSfUM2mSL", "Xsa4cJOkIZbMkuYEGrLd", "kePiLfd7f9Lx99hSV9FM"]
docs = db.collection('my_collection').where("id", "not in", skip_id)
but it seems the above code is not working.
Your .where("id", "not in", skip_id)
means that you're filtering on a field named id
in the document data, not on the document ID.
If you want to filter on the document ID, you can use the special "__name__"
marker, or with firestore_v1.field_path.FieldPath.document_id()
.
Also see:
python-firestore
repo.__name__
and document_id
in the python-firestore
repo
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.