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

287
Visualizações
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
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