0
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。有任何想法吗?

4

1 回答 1

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
于 2013-06-17T06:45:13.747 回答