Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

248
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda