Hi Ross,
Thanks for the reply. Great job on Mongoengine by the way!
> In versions 0.5.2+ there is dirty data tracking, so save() will convert to
> updates if you add or delete data, prior to 0.5 save() updated the whole
> document - so if you didnt get the whole object you could lose data..
Ah, I just realised my machine was on 0.5.1!
I can't always assume I'll be on 0.5.2, so does the following logic
also work?
If I instantiate a new document that uses the same ID as an existing
one, and provide values for the required fields before I save it, and
existing optional fields in the existing document with the same ID,
will be lost, presumably because they are not present in the new
document I instantiated client-side.
To mitigate against this I should do a get() on the id and see if a
document comes back, then update the fields directly with any new
values, then call save(). If I know I'm using 0.5.2+ I don't have to
worry about checking for an existing document first and can just
instantiate one with the same id as an existing one, and the existing
one's optional fields will not be overwritten when I call save() on
the new document.
Right?
Cheers!
Edd