'Search by value to all Firestore collection and subcollections with admin-sdk in Python

I'm making some APIs that among many things are able to retrieve the respective document via a value. My data structure is as follows

Schools (collection) -> Lombardy (doc) -> Milan (collection) -> Milan (doc) - School Test1 (collection) -> 0 (doc) -> document

In the school document there is the following information:

address: School address 1
INFORMATICS {
    4A INF: "GA24HJ"
}

My goal is to retrieve the name of the school (School Test1) and the address using the code GA24HJ. My code:

firestore = firestore.client()

collections = firestore.collections()
        for doc in collections.stream():
            print(f'{doc.id} => {doc.to_dict()}')

Result:

Lombardy => {}

I want to clarify that I have not found anything useful online and that I am using Python and the admin sdk.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source