Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

247
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!