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 に答える