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

156
Vistas
Flatten object in side an array of assosiated table in Sequelize

I have a Sequelize query with multiple associations.

let res = await models.Patients.findAll({
    include: [
        {
            model: models.Physicians,
            required: true,
            attributes: [ 'id' ],
            include: [ {
                model: models.PII,
                required: true,
                attributes: [ 'firstName' ]
            }
    ]
})

The results comes as following:

[{
    patientName: "test",
    physicians: [
            {
                id: '176735',
                PII: {
                         firstName: 'testP'
                     }
            }
    ]
}]

I want the objects in the physicians array to be flat as following:

[{
    patientName: "test",
    physicians: [
            {
                id: '176735',
                firstName: 'testP'
            }
    ]
}]

I tried using: [sequelize.col('PII.firstName'),'firstName'] in the physicians table attributes and I got the error: "Column physicians.PII.firstName does not exists"

Any suggestions please how solve this issue?

about 4 years ago · Juan Pablo Isaza
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