Sequelize:暂时禁用时间戳
Sequelize: temporarily disable timestamps
在 Sequelize.js 中有没有一种方法可以暂时禁用时间戳,最好是针对单个查询?
特别是,我 运行 查询像
MyModel.update({
UserId: 1
}, {
where: {
UserId: 2
}
}).then(...)
而且我不想更新时间戳。我确实希望他们针对与此上下文无关的任何其他查询进行更新。
我试过在 运行 和 update()
之前设置 MyModel.options.timestamps = false
并在之后立即将其设置回 true
,我也试过,只是为了试验,尝试 not 再次将其设置回 true
。时间戳仍然会更新。
对 MyModel.update()
使用 silent
选项。
来自docs:
[options.silent=false] Boolean If true, the updatedAt timestamp will not be updated.
在 Sequelize.js 中有没有一种方法可以暂时禁用时间戳,最好是针对单个查询?
特别是,我 运行 查询像
MyModel.update({
UserId: 1
}, {
where: {
UserId: 2
}
}).then(...)
而且我不想更新时间戳。我确实希望他们针对与此上下文无关的任何其他查询进行更新。
我试过在 运行 和 update()
之前设置 MyModel.options.timestamps = false
并在之后立即将其设置回 true
,我也试过,只是为了试验,尝试 not 再次将其设置回 true
。时间戳仍然会更新。
对 MyModel.update()
使用 silent
选项。
来自docs:
[options.silent=false] Boolean If true, the updatedAt timestamp will not be updated.