I want to make a clone of a model currently being edited.
I've found a couple of ways that almost work. But neither are perfect.
1) model.get('data.attributes')
gets all the attributes except for relationships in camelCase form, generates a new record fine but the relationships are missing of course.
2) model.serialize()
generates a JSON object, with all attributes including relationships. But createRecord
will not handle it well since the object is not camelCased (attributes with underscores like first_name
will not be handled)
After my clone has been created I want to transaction.createRecord(App.Document, myNewModelObject)
change/set a couple of attributes and finally commit()
. Anyone have some insight in how to do this?