I have a form with 2 models in it: here are the models :
model: function(params){
return Ember.RSVP.hash({
customer: this.store.findRecord('customer', params.customer_id),
address: this.store.createRecord('address'),
parameter: this.store.findRecord('parameter',1),
newAddress : 'true'
});
},
When i save these models it creates dulicate records in the store ? Here is may save code :
createAddress: function(model){
this.controller.set('model.address.id_customer_fb', parseInt(this.controller.get('model.customer.id')));
this.controller.set('model.address.id_customer', parseInt(this.controller.get('model.customer.id_customer')));
this.controller.set('model.address.id', this.controller.get('model.parameter.id_last_address')+1);
model.address.save()
.then(()=>{
this.controller.set('model.parameter.id_last_address', this.controller.get('model.address.id'));
model.parameter.save()
.then(()=>{
this.toast.info('Nieuw Adres werd toegevoegd !');
this.transitionTo('customers.customer');
})
.catch((error)=>{console.log(error);
});
})
.catch((error)=>{console.log(error);
});
}
Am i doing something wrong or is there a bug (like mentioned in some posts) in Ember data ?
Aucun commentaire:
Enregistrer un commentaire