Rename node.js sequester timestamp columns
I just started using sequelize, but I have a little problem mapping an existing database.
By default sequelize creates two data columns named createdAt and updatedAt, does anyone know if it can be renamed to something else. For example...
products: sequelize.define('products', {
timestamps: false,
product_id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true
},
product_name: Sequelize.STRING,
product_description: Sequelize.TEXT,
product_created: Sequelize.DATE,
product_updated: Sequelize.DATE
}),
It's still an automatic change to the product_created / product_updated columns on creation and update.
+3
source to share
2 answers
Another update (and two years have passed) and you can do what you want :
products: sequelize.define('products', {
timestamps: false,
product_id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true
},
product_name: Sequelize.STRING,
product_description: Sequelize.TEXT,
product_created: Sequelize.DATE,
product_updated: Sequelize.DATE
}, {
updatedAt: 'product_updated',
createdAt: 'product_created'
});
+4
source to share