Sequelize update no longer works: "The where attribute is missing in the parameter parameter passed for the update"

The official API documentation suggests using it Model.updateas follows:

var gid = ...;
var uid = ...;

var values = { gid: gid };
var where = { uid: uid };
myModel.update(values, where)
.then(function() {
    // update callback
});

But this gives me: "Missing, where the attribute in the parameter parameter is passed for updating." The documents also mention that this use is deprecated. Seeing this error, I think they have already changed it. What am I doing wrong?

+6
source share
2 answers

, . , where Model.update API Model.update where, :

var gid = ...;
var uid = ...;

var values = { gid: gid };
var selector = { 
  where: { uid: uid }
};
myModel.update(values, selector)
.then(function() {
    // update callback
});

!

:

( ). Model.update docs.sequelize.com. , options.where ( []).

+11

, where . :

await DisplayMediaSequence.update({
    default: false
}, {
    where: {}, // <--- here
    transaction
});

await DisplayMediaSequence.update({
    default: true
}, {
    where: {
        id
    },
    transaction
});
0

All Articles