mardi 30 juin 2015

Ember distinguish record which is requested from server with params and without params

I'm trying to get two records from the server without knowing the ID's. The first record is requested without params and the second record with params.

It looks something like this:

model: function(){

  return Ember.RSVP.hash({
    cars: this.store.find('cars').then(function(car){
      return car.get('firstObject');
    }),

    carsWithRange: this.store.find('cars', {date_from: momentLast30Days}).then(function(car){
      return car.get('firstObject');
    })
  });
}

At the moment 'cars' and 'carsWithRange' sometimes returns the same record. I think this is happening because I use car.get('firstObject') from the cars models. Somehow I need to know that 'carsWithRange' is requested with the param 'date_from'.

Does anyone know how to fix this?

FYI I use Ember 1.12.1 with Ember Data 1.0.0-beta.15




Aucun commentaire:

Enregistrer un commentaire