This class can be used on a DS.Model to add a saveBulk functionality.

Saving a lot of data at the same time can be quite inefficient. To solve this issue, you can use the provided model-bulk-save mixin on your ember-data models:

import Model, { attr } from '@ember-data/model';
import { ModelBulkSaver } from 'ember-indexeddb/utils/model-bulk-saver';

export default class extends Model {
  @attr('string') title;
  modelBulkSaver = new ModelBulkSaver(this);
}

Now, you can bulk save this model like this:

let promise1 = model1.modelBulkSaver.saveBulk();
let promise2 = model2.modelBulkSaver.saveBulk();

In the above example, promise1 and promise2 would actually be the same promise, and both of these items would be saved in one transaction. This waits for 100ms before resolving, * so every model that calls saveBulk in this time period will be saved in the same transactions. Note that this function will resolve with all the saved objects.