Ok but this is automatic. You basically created a method to set IDs for subdocuments before inserting the main document.