Reputation: 1744
I've just started using sequelize but I'm having a small issue mapping an existing database.
By default sequelize creates two datatime columns named createdAt and updatedAt, does anyone know if its possible to rename the columns 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
}),
That would still automagically amend the product_created/product_updated columns on creates and updates.
Upvotes: 13
Views: 7597
Reputation: 11388
Another update strikes (and two years pass) and you can do just 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'
});
Upvotes: 24
Reputation: 6241
sadly this is not yet possible. Can you please open an issue on github. I guess this is pretty easy to implement.
Thanks :)
Upvotes: 0