Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

129
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda