There are a couple ways to update values in the Sequelize ORM:
db.Alert.update(
{ url: url },
{
fields: ['url'],
where: {id: id}
}
);
If you have an object, this is also supposed to work:
var alert =
db.Alert.find(
{where: {
id: id,
UserId: req.user.id
}});
alert.update({
url: 'https://www.garysieling.com/blog'
}).then(function() {})
Does not work. TypeError: alert.update is not a function
Probably because find returns a Promise. It should be more like:
db.Alert.find(
{where: {
id: id,
UserId: req.user.id
}}).then(alert => {..})
We need to delete “——activeUsers” : {“ssoid” : “1”,”username” : “LITTA”, “role” : “Engineer”, “projectRole” : null }—–” the json objectt from below json object. Pls help how to do this in sequalize.?
var json={ “projectName” : “1”,
“projectId” : “1”,
“activeUsers” : [
{
“ssoid” : “1”,
“username” : “LITTA”,
“role” : “Engineer”,
“projectRole” : null
},
{
“ssoid” : “2”,
“username” : “SHILPA”,
“role” : “Admin”,
“projectRole” : null
}
]}
not working. same sachin: Does not work. TypeError: alert.update is not a function.
did you check it before publishing it?
This post was written two years ago, so the API may have changed
But… find would return a promise, wouldn’t it? You can’t just assign the lookup to a variable, you need to chain a .then()
This doesn’t seem like an API thing