To fix Unknown column ‘*.createdAt’ in ‘field list’ error with Node.js Sequelize, we add a model with the createdAt
field.
For instance, we write
const users = sequelize.define("users", {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
},
createdAt: {
field: "created_at",
type: Sequelize.DATE,
},
updatedAt: {
field: "updated_at",
type: Sequelize.DATE,
},
//...
});
to add the createdAt
field to the users
model and map it toi the created_at
date field.