最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Error: Missing where attribute in the options parameter passed to findOrCreate. - Stack Overflow

programmeradmin0浏览0评论

I'm trying to use sequelize findOrCreate function, but I'm getting this error:

Error: Missing where attribute in the options parameter passed to findOrCreate. 

This is my code:

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);
            });

I'm trying to use sequelize findOrCreate function, but I'm getting this error:

Error: Missing where attribute in the options parameter passed to findOrCreate. 

This is my code:

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);
            });
Share Improve this question asked Nov 26, 2016 at 17:05 Filipe FerminianoFilipe Ferminiano 8,81127 gold badges113 silver badges180 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8
 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.)

You should switch the arguments so that the object containing the where clause is first, not second. The second argument is the place for default keys.

User.findOrCreate(selector, values)
        .then(function() {
            return done(err, user);
        });
发布评论

评论列表(0)

  1. 暂无评论