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