yozawiratama yozawiratama - 2 months ago 34
Node.js Question

disable updatedAt (update date) field in sequelize.js

i used sequelize-auto to generate schema, and i try to using

findOne()
and i get this error :

Unhandled rejection SequelizeDatabaseError: Invalid column name 'updatedAt'.


in my database table there is no field
updatedAt


for example my table name is
Users
my code is
Users.findOne()
, and there are no
updatedAt
field in
users
table.

db.users= sequelize.import(__dirname + "/models/users");
app.get('/users', function (req, res) {

db.user.findOne().then(function (project) {
res.json(project);
})

});


how to solve it?

Answer

Refer documentation for configuration of Model in Sequelize

In model object of your table should be looks like this.

var user = sequelize.define('user', { /* bla */ }, {
  // don't add the timestamp attributes (updatedAt, createdAt)
  timestamps: false,
  // your other configuration here
});

Check Usage of sequelize-auto-generation module

  1. Create one json file for all model configuration otpions (flag object as defined here).

  2. When executing command you have to pass -a or --addtional option for that where you have to pass json file configuration path.