[Python] Getting list of firestore db subcolletions in document

Discussão em 'Python' iniciado por Stack, Março 18, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to list all subcollections in a document in firestore.

    I've tried the following code from the documentation, but it does not return anything:

    keeper_ref = firestore_db.collection("keeperData").document("1006")
    collections = keeper_ref.collections()
    for collection in collections:
    for doc in collection.stream():
    print(f"{doc.id} => {doc.to_dict()}")


    I know from the firestore web UI, that there are subcollections within this document. Ideally, I simply want a list with all these subcollections. Note that these subcolletions also contain further document-> subcollection nesting...

    Am I missing something about the data model or is there a different function that serves this purpose. I could not find anything in the documentation.

    Continue reading...

Compartilhe esta Página