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

412
Vistas
How to save values in column type range in postgres using Sequelize?

I have a model where I have a column name data_numbers and its type is DataTypes.RANGE(sequelize.INTEGER) I am using the following line of code to create a new row in table models.TABLE.create({ data_numbers: ?? //here is what I should write to save a range of numbers. })

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Here you go. While saving data in column type range you have to assign an array of Range type, like following

const TABLE = sequelize.define(
    "table",
    {
      data_numbers: DataTypes.RANGE(sequelize.INTEGER),
    },
    {
      underscored: true,
      paranoid: true,
      defaultScope: {
        attributes: [
          "id", 
          "data_numbers",
        ],
      },
    }
  );

and while creating new object I added value like following

models.TABLE.create({
    data_numbers: [1, 199]
})
over 4 years ago · Santiago Trujillo Denunciar
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