Query Firebase Firestore documents by the ID

后端 未结 2 1792
日久生厌
日久生厌 2020-12-03 17:57

As I got from \'Cloud Firestore Data Model\' guide \"each document is identified by a name.\" Is it possible to query a collection by that document identifier (which is the

2条回答
  •  北荒
    北荒 (楼主)
    2020-12-03 18:17

    In python you should use full documents names

    from google.cloud import firestore as f
    from google.cloud.firestore_v1.field_path import FieldPath
    
    firestore = f.Client()
    colRef = firestore.collection(u'docs')
    filter = [firestore.document(u'docs/doc1'), firestore.collection(u'docs/doc3')]
    query = colRef.where(FieldPath.document_id(), u'in', filter)
    

提交回复
热议问题