Reputation: 851
I am working on ORM
data base and I don't have createdAt
column in table and I am using Sequelize ORM
for db interaction.
I am getting the following error:
Unhandled rejection SequelizeDatabaseError: Unknown column 'createdAt' in 'field list'
Upvotes: 3
Views: 3210
Reputation: 17
Check your associations of all the models, I also faced the same issue and found that I wrote wrong model name in the associations declaration.
models.Page.belongsTo(models.User, { foreignKey: 'createdBy' });
Upvotes: 0
Reputation: 851
The above error comes when db adapter want to store tiemstamp columns. We can exclude the createdAt/updatedAt column while doing db operation by disabling timestamp.
example.
"define": {
"timestamps": false
}
We can add above line in side the code before calling the models. So I have put the above code inside config.json. Below is the complete code.
{
"development": {
"username": "xxxx",
"password": "xxxx",
"database": "dbName",
"host": "127.0.0.1",
"dialect": "mysql",
"define": {
"timestamps": false
}
}
}
Upvotes: 3