Open rschmukler opened 10 years ago
For arrays probably the best solution is:
dirty
like mongoose's markModified
push
, pop
, ... that updates a stored private array and uses the necessary MongoDB operation http://docs.mongodb.org/manual/reference/operator/update-array/This is how mongoose does it https://github.com/LearnBoost/mongoose/blob/3.8.x/lib/types/array.js#L27
For nested properties I suppose that when there is a defined set of sub properties in the schema like:
Model.attr('obj', {
sub1: Date,
sub2: String
})
(Or another syntax given that the second argument can be used for passing options.) And then transform each sub property using a getter and a setter, for objects without a defined set of sub property I think that the only thing that you can do is using a method like markModified
to be used manually.
when setting nested properties or mutating arrays