Ember-addon-ember-data-model-query
This addon provides a way to add query parameters when handling has-many relationships and depaginate them.
Compatibility
- Ember.js v2.18 or above
- Ember CLI v2.13 or above
Installation
ember install ember-addon-ember-data-model-query
or add them to the package.json and run npm install
Usage
The addon gives the user two mixins adapter-actions
and model-actions
.
Both mixins need to be present in the model and adapter of the type to work properly.
; RESTAdapter;
Model;
The adapter is presented of two functions: findHasMany
and getDepaginated
.
The override of the findHasMany
give the user the ability to set queryParams to the relationship get request and/or get it depaginated. Currently it works with sirenJSON and the meta
property returned from the API.
The getDepaginated
method on the other hand exposes the depaginated logic used in the findHasMany
.
Example usage:
Lets say in the model you have this property customFoo
Model;
Now in the adapter:
; RESTAdapter;
In order to keep the functionality of ember-data findHasMany
to use the addon you need to customize your relationship properties in the model. Currently in the options
you need to pass { depaginated: true }
.
Model;
Future ideas
- Add option to cache the result for
hasMany
relationship