我尝试使用sequelize findOrCreate函数,但我收到此错误:
Error: Missing where attribute in the options parameter passed to findOrCreate.
这是我的代码:
var values = { slack_id: profile.id, name: profile.user };
var selector = { where: { slack_id: profile.id } };
User.findOrCreate(values, selector)
.then(function() {
return done(err, user);
});
答案 0 :(得分:3)
Missing where attribute in the options parameter passed to
findOrCreate. Please note that the API has changed, and is now options
only (an object with where, defaults keys, transaction etc.)
您应该切换参数,以便包含where子句的对象是第一个,而不是第二个。第二个参数是默认键的位置。
User.findOrCreate(selector, values)
.then(function() {
return done(err, user);
});