Add Property to Object that is returned by Sequelize FindOne

前端 未结 5 1665
孤独总比滥情好
孤独总比滥情好 2020-12-29 05:09

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         


        
5条回答
  •  不思量自难忘°
    2020-12-29 05:33

    The following works for sequelize v4.

    ...
    const order = Order.findOne(criteria);
    order.setDataValue('additionalProperty', 'some value');
    ...
    

    Hope this helps. It's a bit late but in case people are still looking for answers.

提交回复
热议问题