vendredi 20 novembre 2015

Many to Many Relationships with Ember

It seems like this question has been asked quite a few times before but all the previous questions are over a year old and just noted that people were working on it.I'm not sure if this has since been resolved.

I have a three models: Site, Flight, FlightDataSet

A site has many flights. A flight has one flightDataSet. A site therefore has many flightDataSets through it's flights.

I am trying to graph these data sets and need to get all the data sets that belong to a specific site.

I tried something like:

var flightDataSets =  DS.PromiseArray.create();
this.get('activeSite.flights').forEach(function (flight) {
  earthworkAnalyses.pushObject(flight.get('earthworkAnalysis'));
});

Which I though might work because this.get('activeSite.flights') returns a promise but PromiseArray does not like to be populated that way.

If I make flightDataSets a normal array they will sometimes be unfulfilled promises when I need to use them later which doesn't work.

So how can I get all the flightDataSets for a site?




Aucun commentaire:

Enregistrer un commentaire