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

Fil*_*ano 2 javascript node.js sequelize.js

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. 
Run Code Online (Sandbox Code Playgroud)

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);
            });
Run Code Online (Sandbox Code Playgroud)

l2y*_*sho 6

 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.)
Run Code Online (Sandbox Code Playgroud)

您应该切换参数,以便包含 where 子句的对象是第一个,而不是第二个。第二个参数是默认键的位置。

User.findOrCreate(selector, values)
        .then(function() {
            return done(err, user);
        });
Run Code Online (Sandbox Code Playgroud)