Reputation: 103
I´ve the following code, imports the model
I get the error in line 11. Doesn´t exist method success
Upvotes: 3
Views: 4056
Reputation: 487
in addition to @robertklep answer, success() is deprecated so you need then() function instead.
The result would be:
sequelize.sync().then(function() {
Quiz.count().then(function (count){
if(count === 0) {
Quiz.create({
pregunta: 'Capital de Italia',
respuesta: 'Roma'
})
.then(function(){console.log('log')});
}
});
});
The same in quiz_controller.js
Upvotes: 2
Reputation: 203329
Sequelize uses the bluebird
package for its Promise implementation, and as you can see here, its API doesn't support .success()
(which also isn't a valid Promises/A+ method).
Instead, use .then()
:
sequelize.sync().then(function() {
...called if successful...
}, function(err) {
...called if an error occurred...
});
Upvotes: 9