Answers for "saving some fields of an instance in sequelize"

0

saving some fields of an instance in sequelize

const jane = await User.create({ name: "Jane" });
console.log(jane.name); // "Jane"
console.log(jane.favoriteColor); // "green"
jane.name = "Jane II";
jane.favoriteColor = "blue";
await jane.save({ fields: ['name'] });
console.log(jane.name); // "Jane II"
console.log(jane.favoriteColor); // "blue"
// The above printed blue because the local object has it set to blue, but
// in the database it is still "green":
await jane.reload();
console.log(jane.name); // "Jane II"
console.log(jane.favoriteColor); // "green"
Posted by: Guest on January-03-2022

Code answers related to "saving some fields of an instance in sequelize"

Code answers related to "Javascript"

Browse Popular Code Answers by Language