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

251
Vistas
Why does 'this.username' in my Sequelize model return a 'Potentially invalid usage of this' warning but other fields do not?

If I rename the username attribute, the error goes away. 'username' sets this warning off for whatever reason though, which to me is a bit of a headscratcher. I am using IntelliJ Ultimate. Is this perhaps just IDE specific and am I safe to ignore that warning?

username: {
  type: DataTypes.STRING,
  allowNull: false,
  validate: {
    len: [2, 32],
    notNull: true,
  },
  get() {
    return this.getDataValue('username');
  }
},
fullUsername: {
  type: DataTypes.VIRTUAL,
  get() {
    return `${this.username}#${this.discriminator}`;
  },
  set() {
    throw new Error("user field is not settable.");
  }
},
discriminator: {
  type: DataTypes.INTEGER,
  allowNull: false,
  validate: {
    min: 4,
    max: 4,
    notNull: true,
  }
},
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Inside getters you should always use getDataValue to avoid potential recursive calls when one getter uses another one and vice versa.

fullUsername: {
  type: DataTypes.VIRTUAL,
  get() {
    return `${this.getDataValue('username')}#${this.getDataValue('discriminator')}`;
  },
  set() {
    throw new Error("user field is not settable.");
  }
},
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