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

171
Views
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 answers
Answer question

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 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!