I am trying to save a one to many in emberfire and here is the scenario.
I have a list of territories in the model with each territory that can have many dealers. I also have a list of dealers that are in the model that can have one territory assigned to it via a dropdown in a form.
I have setup the territory dropdown select but I am confused on creating the relationship and then saving it back to firebase.
From what I have read I need to save the child first which would be dealer then push the dealer object into the territory and then save? I've been struggling to write this out in code fairly new with ember.
This is what I have written out so far but doesn't seem to work.
let addTerritory = this.get('model.territory');
addTerritory.get('dealer').addObject(dealer);
dealer.save().then(function() {
return addTerritory.save();
});
Any help is appreciated
Thanks!
Aucun commentaire:
Enregistrer un commentaire