mardi 21 février 2017

how to filter model to get data in realtime in emberfire

so i have quota model like this :

 export default DS.model.extend({
 quota : DS.attr('number'),
 sellerId: DS.attr('string'),
 buyerId:DS.attr('string') });

and i have assignQuota routes with dynamic segment like this:

 this.route('assignQuota', {path:'/assignQuota/:buyer_id'}

and in assignQuota.js :

    export default Ember.Route.extend({
    model(params) {
    const sellerId = this.get("session").get("uid");
    return this.store.query('quota',{
    orderBy:'buyerId',
    equalTo: params.buyer_id
     }).then(function(quota){
      return quota.filterBy('sellerId',sellerId)    
     }); 
     }
     });

and in my template (simplify) is like this:

      
            

          

it worked but if someone add data or delete data in quota model, the list didn't update automatically in the template.

The template only refresh after i refresh the browser. The funny thing is if I use ember inspector to inspect the data for quota, it shown that the model already changes if someone changes the model but the template didn't reflect the changes.

please help

thanks




Aucun commentaire:

Enregistrer un commentaire