Sequelize update does not work anymore: quot;Missing where attribute in the options parameter passed to updatequot;(Sequelize update 不再起作用:“在传递给 update 的选项参数中缺少 where 属性)
问题描述
官方 API 文档 建议像这样使用 Model.update:
var gid = ...;
var uid = ...;
var values = { gid: gid };
var where = { uid: uid };
myModel.update(values, where)
.then(function() {
// update callback
});
但这给了我:传递给更新的选项参数中缺少 where 属性".文档还提到不推荐使用这种用法.看到这个错误让我想,他们已经改变了它.我做错了什么?
But this gives me: "Missing where attribute in the options parameter passed to update". The docs also mention that this usage is deprecated. Seeing this error makes me think, they already changed it. What am I doing wrong?
推荐答案
显然,文档还没有更新.但是 where 行">Model.update
API 文档 建议在您的选择前加上 where
,如下所示:
Apparently, the docs have not been updated yet. But the table's where
row of the Model.update
API docs suggests prefixing your selection with where
, like so:
var gid = ...;
var uid = ...;
var values = { gid: gid };
var selector = {
where: { uid: uid }
};
myModel.update(values, selector)
.then(function() {
// update callback
});
而且它有效!
更新:
文档已更新(文档也已移动).查看 docs.sequelize.com 上的 Model.update.请注意,options.where
不是可选的(它不在括号 [] 中).
The docs have since been updated (and the docs have also been moved). Check out Model.update on docs.sequelize.com. Note that options.where
is not optional (it is not in brackets []).
这篇关于Sequelize update 不再起作用:“在传递给 update 的选项参数中缺少 where 属性"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Sequelize update 不再起作用:“在传递给 update 的选项参数中缺少 where 属性"


基础教程推荐
- 自定义 XMLHttpRequest.prototype.open 2022-01-01
- Chart.js 在线性图表上拖动点 2022-01-01
- 我可以在浏览器中与Babel一起使用ES模块,而不捆绑我的代码吗? 2022-01-01
- 用于 Twitter 小部件宽度的 HTML/CSS 2022-01-01
- Electron 将 Node.js 和 Chromium 上下文结合起来意味着 2022-01-01
- 直接将值设置为滑块 2022-01-01
- html表格如何通过更改悬停边框来突出显示列? 2022-01-01
- Vue 3 – <过渡>渲染不能动画的非元素根节点 2022-01-01
- 如何使用JIT在顺风css中使用布局变体? 2022-01-01
- 如何使用TypeScrip将固定承诺数组中的项设置为可选 2022-01-01