I have a simple model, with an _id
column as expected, but there is a secondary id which I would like to default to the same value of the _id
column. This is currently what the model looks like:
const sequelize = app.get('sequelize')
sequelize.define('myTable', {
_id: {
type: Sequelize.INTEGER,
allowNull: false,
primaryKey: true,
autoIncrement: true
},
otherId: {
type: Sequelize.TEXT,
allowNull: false
}
someField: {
type: Sequelize.TEXT,
allowNull: false
}
})
So if I don't pass in a value for otherId
when I am inserting a new row, I'd like it to be the same value as _id
can this be done? If so, how can I achieve that?