dimanche 30 août 2015

Add Ember Data query helper method

I'm using Ember API with a JSON API backend. The API accepts filters like this:

/users?filter[simple][name]=John

Right now, whenever I want to make a query, I'm doing this:

this.store.query('users', {
  filter: {
    simple: {
      name: 'John'
    }
  }
});

It would be nice to avoid this verbosity by adding a helper function that works like this:

this.store.simpleQuery('users', { name: 'John' });

That function would pass its arguments directly to query(), just wrapping the query in { filter: { simple: ... } }.

Is this possible? How do I do this?




Aucun commentaire:

Enregistrer un commentaire