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. })
CodePudding user response:
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]
})