-6

SUPPOSE I HAVE THIS FIRESTORE DATABASE:

collection > document_1 > user > doc1 > field1: value1
field2: value2
///////////> document_2 > user > doc2 > field3: value3

1 Answers1

0

If I understand your post correctly you want to access a specific subcollection of all documents. If so, you are looking for a collection group query, which reads documents from all collections with a specific name.

Accessing that in Python is (according to the documentation linked above) done with:

museums = db.collection_group(u'landmarks')\
    .where(u'type', u'==', u'museum')
docs = museums.stream()
for doc in docs:
    print(f'{doc.id} => {doc.to_dict()}')

So this would query across all documents in collections named u'landmarks, no matter where in the database those collections exist.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • I want to acces every document inside the subcollection user for all document inside the collection collection – ernest fokam Sep 21 '21 at 21:32
  • That's possible too. See https://stackoverflow.com/questions/68049541/collectiongroupquery-but-limit-search-to-subcollections-under-a-particular-docum/68049847#68049847 – Frank van Puffelen Sep 21 '21 at 23:30