import Ember from 'ember'; export default Ember.Controller.extend({ appName: 'Ember Twiddle', init() { this._super(...arguments); let store = this.get('store'); let user = store.createRecord('person', { name: 'Chris' }); let father = store.createRecord('person', { name: 'Tom' }); let friend1 = store.createRecord('person', { name: 'Rebecca' }); let friend2 = store.createRecord('person', { name: 'Wesley' }); let friends = user.friends; friends.addObject(friend1); friends.addObject(friend2); user.father = father; this.user = user; // note if we only wanted to save specific related records // and not all related records we could pass adapterOptions // into this save with a list of which related props the transaction should include // the transaction class here would need to be updated to then include only those vs the current recursive strategy // the setTimeout here is just to add some delay so we // can observe the states change new Promise(resolve => setTimeout(resolve, 1500)) .then(() => user.save()); } });