c.models.car.findOne where: {id: 1}, (err, car)->
car['seat'] = 1 #seat is not originally in the car object but I would like to add it
car['color'] = 'red' #color is originally in car and is changed
console.log car
The issue is that color is being changed, but seat is not being added. When I do typeof car
it returns object
. Any ideas?
I think you are using an ORM which decline the assignment. Try to use this:
c.models.car.findOne where: {id: 1}, (err, car)->
car = car.toObject(); # or car = JSON.parse(JSON.stringify(car))
car['seat'] = 1 #seat is not originally in the car object but I would like to add it
car['color'] = 'red' #color is originally in car and is changed
console.log car