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

458
Views
¿Cómo devolver el resultado del modelo incluido en el mismo nivel del modelo principal en Sequelize?

Este es el código y el resultado que he hecho en mi proyecto. Me gustaría obtener el resultado de incluir el modelo en el mismo resultado con el modelo principal. el siguiente código es lo que he hecho.

Secuela de consulta:

 User.findAll({ include: [{ model: Position, attributes: ['POSITION_NAME'], } ] }).then(user => { res.json({ data: user }) }).catch(error => { console.log(error) })

resultado que obtengo

 [ { "ID": 2, "NAME": "AAA", "LAST_NAME": "BBB", "Position": { "POSITION_NAME": "ວິຊາການສັນຍາຈ້າງ" } } ]

resultado que quiero:

 [ { "ID": 2, "NAME": "AAA", "LAST_NAME": "BBB", "POSITION_NAME": "ວິຊາການສັນຍາຈ້າງ" } ]
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

intenta así

 User.findAll({ attributes: ["ID", "NAME", ["Position.POSITION_NAME", "POSITION_NAME"]], include: [{ model: Position, attributes: [], } ], raw:true }).then(user => { res.json({ data: user }) }).catch(error => { console.log(error) })
over 4 years ago · Santiago Trujillo 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!