Mysql
 sql >> Datenbank >  >> RDS >> Mysql

.findOrCreate()-Fehler erhalten

 User.findOrCreate({
  where: {
    username: "johny",
    password: "pass",
    email: "johny93[###]example.com"
  },
  defaults: {
    //properties to be created 
  }
}).then(function(user){
  var created = user[1];
  user = user[0];
  console.log(user.values);
}).fail(function(err){
   console.log('Error occured', err);
});

https://github.com/sequelize/sequelize/wiki/Upgrading-to -2,0

BEARBEITEN:Wie @Domi betonte, ist es besser, 'spread' anstelle von 'then'

zu verwenden
User.findOrCreate({
  where: {
    username: "johny",
    password: "pass",
    email: "johny93[###]example.com"
  },
  defaults: {
    //properties to be created 
  }
}).spread(function(user, created){
  console.log(user.values);
}).fail(function(err){
   console.log('Error occured', err);
});