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

224
Views
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

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

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;
    }
  }
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!