No method success in sequelize.sync

I am using the following code: imports the model enter image description here

I am getting error on line 11. There is no method success

enter image description here

+3


source to share


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


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







All Articles