gpt4 book ai didi

javascript - Sequelize 更新不再起作用 : "Missing where attribute in the options parameter passed to update"

转载 作者:数据小太阳 更新时间:2023-10-29 05:02:25 25 4
gpt4 key购买 nike

The official API documentation建议像这样使用 Model.update:

var gid = ...;
var uid = ...;

var values = { gid: gid };
var where = { uid: uid };
myModel.update(values, where)
.then(function() {
// update callback
});

但这给了我:“传递给更新的选项参数中缺少 where 属性”。文档还提到这种用法已被弃用。看到这个错误让我想,他们已经改变了它。我做错了什么?

最佳答案

显然,文档还没有更新。但是表的 wherethe Model.update API docs建议在您的选择前加上 where 前缀,如下所示:

var gid = ...;
var uid = ...;

var values = {
gid
};
var selector = {
where: {
uid
}
};
await myModel.update(values, selector);
// done!

而且有效!

更新:

文档已更新(文档也已移动)。查看Model.update on docs.sequelize.com .请注意,options.where 不是可选的(它不在方括号 [] 中)。

关于javascript - Sequelize 更新不再起作用 : "Missing where attribute in the options parameter passed to update",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26581715/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com