sequelize – 更新行而不更改updated_at字段

我在节点开发中使用sequelize.js库作为ORM。 使用sequelize更新行时, “updated_at”字段已更改为当前时间戳。 我想知道如何防止这种情况? 在不更改“updated_at”字段的情况下,我想使用sequizeize API更新其他字段,而不是运行原始查询。

在您的模型定义中,您可以closures特定字段的时间戳 。

如果你想sequelize来处理时间戳,但只想要其中的一些,或者想要你的时间戳被称为别的东西,你可以重写每个列单独:

var Foo = sequelize.define('foo', { /* bla */ }, { // don't forget to enable timestamps! timestamps: true, // I don't want createdAt createdAt: false, // I want updatedAt to actually be called updateTimestamp updatedAt: 'updateTimestamp' // And deletedAt to be called destroyTime (remember to enable paranoid for this to work) deletedAt: 'destroyTime', paranoid: true }); 

否则,您可以closures时间戳并根据需要手动处理它们。