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

160
Views
Sequelize. How to join a couple of tables and make a single object of data (without nested objects)

I am using Sequelize ORM for Postgres db. My tables and associations look like:

enter image description here

My associations:

Users.hasMany(Options, {
  foreignKey: 'userId'
});
Options.belongsTo(User);

Users.hasMany(Finders, {
  foreignKey: 'userId'
});
Finders.belongsTo(User);

How can I make a query using Sequelize to get Users data and associated data from tables Options and Finders in the same object (without nested objects)? The query result should be:

[
  {
    id: 1,
    name: 'Mark',
    option: 'opt1',
    finder: 'films'
  },
  {
    id: 1,
    name: 'Mark',
    option: 'opt2',
    finder: 'films'
  },
  {
    id: 2,
    name: 'Lalo',
    option: 'opt3',
    finder: 'books'
  },
]
about 4 years ago · Santiago Trujillo
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!