ember-batch-request
v0.0.24
Published
Ember Addon for making Batch Requests
Downloads
59
Readme
ember-batch-request
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
Getting Started
As any other ember-cli add on, run:
ember install ember-batch-request
Setup
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)
Usage
BatchCreate
this.store.batchCreate(arrayOfObjects).then((response) => { });
BatchUpdate
this.store.batchUpdate(arrayOfObjects).then((response) => { });
BatchDelete
this.store.batchDelete(arrayOfObjects).then((response) => { });
How to skip Store Updates during Create or Update
Just pass the option { skipStoreUpdate: true } in batchCreate or batchUpdate
this.get('store').batchCreate(arrayOfObjects, { skipStoreUpdate: true })
Response
{
completedResponses: [],
errorResponses: []
}
ToDo
Update the store on creates
Contributing
If you would like to contribute, you can fork the project, edit, and make a pull request.
Tests
Please make sure that the test pass by running ember test. If you had a new functionality, add tests for it.
Note
Currently works with JSON API spec