问题描述
Ember公司数据的 DS.RESTAdapter
包括 bulkCommit
属性。我找不到什么这样做/手段,除了批量提交VS批量犯一些模糊的引用的任何文档。
Ember Data's DS.RESTAdapter
includes a bulkCommit
property. I can't find any documentation about what this does/means, other than some vague references to batch committing vs bulk committing.
起初我以为这将意味着我只能更新一次一个记录,但我现在有将其设置为假
,我仍然能够更新同时多条记录使用:
Initially I assumed it would mean I could only update a single record at a time, but I currently have it set to false
, and I'm still able to update multiple records at the same time using:
this.get('store').commit();
那么究竟是什么 bulkCommit
设置为false,并将其设置为之间的区别真正
?在什么情况下我会用一个,而不是其他?
So what is the difference between setting bulkCommit
to false and setting it to true
? In what situation would I use one instead of the other?
推荐答案
剩下的适配器支持批量提交,让您可以一次修改几个记录时提高性能。例如,假设您要创建3个新的记录。
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();
这将导致3 API调用来邮报/人。如果启用了 bulkCommit
功能
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();
然后烬数据将只是一个API调用POST对所有3条记录细节'/人。显然,并非每一个API是要支持这一点,但如果你做它可以真正提高性能。
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.
据我所知没有这个文件还,但你可以看到它在下面的单元测试工作:创建几个人(含bulkCommit)做一个POST /人,与数据散列阵列
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
这篇关于什么是bulkCommit意味着上下文Ember的RestAdapter?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!