purekid / mongodm

MongoDB ORM that includes support for references,embed and multilevel inheritance.
MIT License
200 stars 47 forks source link

Edit and object #76

Closed joesonw closed 10 years ago

joesonw commented 10 years ago

I have a object field which stores several different information depends on the instance. Is there a way to modify the object's data and then save it? Coz now it's not working as expected, like codes below.

$item->obj->value+=1; $item->save();

this does not work

jrschumacher commented 10 years ago

@joesonw what does your model look like? You should define the object as an embed type.

Generally if a value is an object and not defined in the model it isn't saved. This is because objects are complex structures. Not only do they have values but they also have methods, etc. So if you don't define the schema then we don't know what to do with it.

jrschumacher commented 10 years ago

Sorry obj should be defined as embed type. See the tests for more detailed examples.