What Does bulkCommit Mean In The Context Of Ember's RestAdapter?

∥☆過路亽.° 提交于 2019-12-04 19:29:53

The REST adapter supports bulk commits so that you can improve performance when modifying several records at once. For example, let's say you want to create 3 new records.

var tom = store.createRecord(Person, { name: "Tom Dale" });
var yehuda = store.createRecord(Person, { name: "Yehuda Katz" });
var mike = store.createRecord(Person, { name: "Mike Grassotti" });
store.commit();

This will result in 3 API calls to POST '/people'. If you enable the bulkCommit feature

set(adapter, 'bulkCommit', true);
var tom = store.createRecord(Person, { name: "Tom Dale" });
var yehuda = store.createRecord(Person, { name: "Yehuda Katz" });
var mike = store.createRecord(Person, { name: "Mike Grassotti" });
store.commit();

then ember-data will make just one API call to POST '/people' with details for all 3 records. Obviously not every API is going to support this, but if yours does it can really improve performance.

AFAIK there is not documentation for this yet but you can see it working in the following unit test: creating several people (with bulkCommit) makes a POST to /people, with a data hash Array

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!