How to Querying Nested Arrays in Firestore with Firebase Admin Python

23 Views Asked by At

I have a data structure in Firestore that contains nested arrays, as shown in the following JSON example:

{
    "courses": [
        {
            "name_courses": "ECONOMIC",
            "schedule": [
                {
                    "date": "22-01-2024",
                    "time": "14.00 - 15.40 ",
                }
            ],
        },
        {
            "name_courses": "STATISTIC",
            "schedule": [
                {
                    "date": "23-01-2024",
                    "time": "14.30 - 15.40 ",
                }
            ],
        }
    ]
}

I want to query Firestore to retrieve documents that have a specific date value within the nested array courses.schedule.date. For example, if I want to retrieve documents that have the date value of 23-01-2024, I want to get all documents that have an element in the courses.schedule array with the matching date value.

I am using Python with the firebase_admin module to interact with Firestore. I have tried using the array_contains and array_contains_any methods, but I have been unsuccessful in retrieving the desired documents.

I so confusing in understanding how to query nested arrays in Firestore using Firebase Admin Python. Thank you for your help and time in assisting me with this question.

0

There are 0 best solutions below