hmarr/mongoengine — Issue #349: Cascading saves only saves previously existing Documents
Author: mhermans
Created: 2011-11-03 16:40:31+00:00
State: open

With the introduction of cascading saves, I'm interested in the possibility of saving all referenced Documents, regardless of whether they already exist or not.

Currently, you get a "You can only reference documents once they have been saved to the database" validation error if some of the referenced Documents are not previously saved (see [here](http://pastie.org/2805095) for a basic example).

Feel free to close if this request is to specific/difficult, or if there is an easy workaround that I'm missing.

My use-case: I parse [XBRL](http://en.wikipedia.org/wiki/XBRL) records, which results per record in one Organisation object and a lot of referenced Organisation, Person, Location, etc. objects. Some of which are loaded/existing, some of which are newly created from that record, and all of them can be referencing each other.

It would be easier if I could just save() the main Organisation object, recursively saving the referenced objects without worrying/tracking which referenced objects are new.