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

322
Vistas
Sequelize getters do not run on model.findall( { raw:true } )

I have a photo attribute in one of my Sequelize models. I have a getter for it.

 photo: {
        type: Sequelize.STRING,
        get: function () {
            if (this.getDataValue("photo"))
                return process.env.IMAGE_PREFIX + this.getDataValue("photo")
            else
                return this.getDataValue("photo")
        }
    },

but when i want to findall records in this model with ({raw:true}) getter doesn't work.

  const categories = await Category.findAll({
            limit: parseInt(limit),
            offset: parseInt(offset),
            raw: true,
            where: {
                title: { [Op.like]: '%' + searchString + '%' }
            }
        });

if i use ({plain:true}) instead , just finds one record.

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

0

Due to newer version of sequelize as documentation itself says:

Getters wont run with instance.get({ raw: true }), use instance.get({ plain: true })

You can read more about it here

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