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
问题是颜色正在改变,但是没有添加座位。当我typeof car
时,它会返回object
。有什么想法吗?
答案 0 :(得分:1)
我认为您正在使用ORM来拒绝分配。试着用这个:
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