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

411
Views
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 answers
Answer question

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