No method success in sequelize.sync
2 answers
Sequelize uses a package bluebird
to implement a Promise and as you can see here , its API does not support it .success()
(which is also not a valid Promises / A + method).
Use instead .then()
:
sequelize.sync().then(function() {
...called if successful...
}, function(err) {
...called if an error occurred...
});
+8
source to share
in addition to @robertklep's answer, success () is deprecated, so you need the then () function.
Result:
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')});
}
});
});
Same in quiz_controller.js
+2
source to share