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

286
Views
How to access the values of record sequelize

I am attempting to insert data into a Postgresql database from an Express.js server using Sequelize.

Before inserting the data into the DB, I need to program to look and see if the data is already inside the table. The data can belong to one person for one day and sometimes there is already data associated with the specific person for the specific day. It is a find or create function that is utilized like so,

record.findOrCreate({
  where: {
    date: data.date,
    name: data.name,
  },
  defaults: data,
})

I need to see if the person's name matches the data being inserted, but I would like to test the value of the name currently in the database as being a substring on the data name being inserted. Is there a way to do this with sequelize? The logic being something similar to what is below.

WeeklyChargeRecord.findOrCreate({
  where: {
    weekend: data.weekend,
    name: data.name.includes(name)
  },
  defaults: data,
})

The reason I am attempting this method is that sometimes the names for each person may include their full name (first, last, & middle names) for that data that is being inserted into the data base. But the data already in the data base is just their first and last names.

about 4 years ago · Juan Pablo Isaza
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!