Adapter add on for making Batch Requests in Ember Applications.
- Customizable Adapter
- Returns Success and Failure responses
- Ability to skip store update in bulk scenario
- Create or Update or Delete N records in 1 XHR call
As any other ember-cli add on, run:
ember install ember-batch-request
Since the Rails middleware depends on the url /api/v1/batch_sequential
or /api/v1/batch_sequential
, please add the following config to environment.js
ENV.apiNamespace = 'api/v1';
ENV.apiBatchUrl = 'batch_parallel'; (or batch_sequential)
BatchCreate
this.store.batchCreate(arrayOfObjects).then((response) => { });
BatchUpdate
this.store.batchUpdate(arrayOfObjects).then((response) => { });
BatchDelete
this.store.batchDelete(arrayOfObjects).then((response) => { });
Just pass the option { skipStoreUpdate: true } in batchCreate or batchUpdate
this.get('store').batchCreate(arrayOfObjects, { skipStoreUpdate: true })
{
completedResponses: [],
errorResponses: []
}
Update the store on creates
If you would like to contribute, you can fork the project, edit, and make a pull request.
Please make sure that the test pass by running ember test. If you had a new functionality, add tests for it.
Currently works with JSON API spec