• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Pruebas Online
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

166
Vistas
How to modify value in attributes sequelize?

I have a query like this :

const rows = await Leaderboard.findAll({
      where: {
        app_type_id: appId,
        ...filterWhereQuery,
        emp_id: dataProgress.submited
      },
      include: [
        ...leaderboardFavouriteInclude,
        {
          model: UserEmployee,
          as: 'user',
          attributes: ['emp_id', 'emp_full_name', 'emp_email', 'is_invited', ...empInfo]
        },

I want to modify the emp_email value in UserEmployee model. The email is would be return like abc@gmail.com but i want to remove the domain email and the result is should be abc for the emp_email.

How to solve case like that ? Thanks

almost 3 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You need to use a getter for a emp_email field like this:

  emp_email: {
    type: DataTypes.STRING,
    get() {
      const rawValue = this.getDataValue('emp_email');
      return rawValue ? rawValue.split('@')[0] : null;
    }
  }
almost 3 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 Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda