ember-data-model-fragments
ember-data-model-fragments copied to clipboard
Deleting an unsaved fragment from store
Hello, I'm very sure I'm doing this incorrectly. I have a route for creating a model setup as shown:
export default Route.extend(AuthenticatedRouteMixin, {
model() {
return RSVP.hash({
systemDatasource: this.store.createRecord('system-datasource', {
name: null,
basePath: null,
datasourceType: null,
s3: this.store.createFragment('system-datasource-s3', {
'bucket': null,
'basePath': null,
'accessKey': null,
'secretKey': null
}),
sftp: this.store.createFragment('system-datasource-sftp', {})
}),
datasourceList: ['s3','sftp']
})
},
actions: {
discard() {
let systemDatasource = this.modelFor(this.routeName).systemDatasource;
systemDatasource.deleteRecord();
this.transitionTo('settings.system-datasources');
}
}
});
When I call the discard()
method (i.e. user decides to abort creating a new object), I notice the uncommitted system-datasource
model is removed from the store correctly.
However, the system-datasource-s3
and system-datasource-sftp
models are left behind:
Can you kindly advise on how I can go about removing those unsaved fragments from the store? Thank you so much!