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 属性"


- 失败的 Canvas 360 jquery 插件 2022-01-01
- Flexslider 箭头未正确显示 2022-01-01
- addEventListener 在 IE 11 中不起作用 2022-01-01
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- 400或500级别的HTTP响应 2022-01-01