lundi 28 septembre 2015

emberjs find then filter

In emberjs, considering the following data (only showing 1 record, normally there would be multiple records):

{ "service": [{
    "service-_id":"service_5606ece79bdb05546479739866",
    "service-_rev":"5-62dc477c13ef3ea92869bcdf1a67f1a6",
    "service-company-name":"ABC co.",
    "service-address":"1 2 3 Main Street",
    "service-address-line-2":"",
    "service-city":"asfd",
    "service-state-current":"NY",
    "service-zip":"12345",
    "service-phone":"111",
    "service-fax":"",
    "service-email":"asdf@adsf.com",
    "service-category-current":"web",
    "service-type":"service",
    "id":"service_5606ece79bdb05546479739866"
}]}

If I want to return all the records, I can simply do this:

App.ServicesRoute = Ember.Route.extend({
    model: function(){
        return this.store.find('service');
    }
});

However, let's say I want to return all the records that have the current category as 'web'. So in the example data, there is this key: service-category-current

How would I adjust my model to find 'service' then filter where service-category-current = 'web' ?




Aucun commentaire:

Enregistrer un commentaire