I am trying to add a property to a sequelize instance before passing it back to the client.
router.get(\'/cats/1\', function (req, res) {
Cat.findOne({w
What works for me is to use setDataValue
router.get('/cats/1', function (req, res) {
Cat.findOne({where: {id: 1}})
.then(function (cat) {
cat.setDataValue("name", "Lincoln");
res.json(cat);
});
});
Specs for the function
public setDataValue(key: string, value: any)
Update the underlying data value
Params:
Name Type Attribute Description
key string key to set in instance data store
value any new value for given key
Source: https://sequelize.org/master/class/lib/model.js~Model.html#instance-method-setDataValue