Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

125
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda