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

170
Vistas
Get parent object, by nested property

I have the following object, an array with databases, each containing a collection of tables, each containing a collection of columns.

Console Output

I want to obtain the parent table, given the Id of a column and tried to avoid iterating over the collection. Just a very simple clean single line.

I was initially trying but quickly was challenged by the fact Tables is not an array but a collection which doesn't support .some statements.

let table = schema.find((database,index) => database.Tables.some((column,index) => column.Id === 1234));

Is there a smart way or conversion trick that I have overlooked that prevents me from having to iterate the entire structure?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Use Object.values() to get an array of columns from your Tables object:

let table = schema.find(database => Object.values(database.Tables).some(column => column.Id === 1234));

Alternately, you could use Object.keys() and write it like this:

let table = schema.find(database => Object.keys(database.Tables)
                                          .some(columnName => database.Tables[columnName].Id === 1234));
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