Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

288
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda