Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

124
Views
Get all collections with sub-collection in Firestore

I have a collection of countries and for each document of it, I have a collection of cities.

I want to get all countries and their cities like the array below. I am using NodeJs SDK.

[
    {
        "country": {
            "codeISO3166": "NL",
            "name": "Netherlands",
            "id": "47891a32-6eb3-4516-9ca1-b1ae16f9fcd3",
            "isEnable": true
        },
        "cities": [
            {
                "name": "Amsterdam",
                "id": "a2394abb-937c-4ba1-92cd-c2ffa7f8d3b2",
                "isEnable": true
            },
            {
                "name": "Utrecht",
                "id": "2dcae8be-4ef3-4f2f-a594-a0019b2c234a",
                "isEnable": true
            }
        ]
    },
    {
        "country": {
            "codeISO3166": "UK",
            "name": "United Kingdom",
            "id": "05236cab-dfdf-47ba-b7ed-b34fe6320183",
            "isEnable": true
        },
        "cities": [
            {
                "name": "London",
                "id": "a47a7c71-b0a2-4ba4-9170-2a5a9fed3757",
                "isEnable": true
            },
            {
                "name": "Liverpool",
                "id": "e6ac7fd7-aba3-45ab-8e13-e29f7dc35b04",
                "isEnable": true
            }
        ]
    }
]
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

There is no way to get a country and all its cities with one read operation.

Reads in Firestore are shallow, and only return documents from one collection or from all collections with a given name.

The closest you can get is:

  • one read for all documents in the countries collection
  • one collection group query for all documents in all cities subcollections.
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!