防止单个项目的Ember Data批量提交?

时间:2013-02-28 09:59:44

标签: ember-data

我需要Ember Data来批量更新我的一个模型。所以我设置了

  bulkCommit: true
DS.RESTAdapter中的

。但现在它甚至使用批量提交来更新单个记录!

这是非常意外的行为。

那么当超过1项提交时,如何修改Ember数据以仅使用批量提交?

1 个答案:

答案 0 :(得分:0)

以下是我现在所做的事情:

 updateRecords: function(store, type, records) {
    var arr;
    arr = records.list;
    if (arr.length === 1) {
      return this.updateRecord(store, type, arr[0]);
    } else {
      return this._super(store, type, records);
    }
  }

检查records是否包含单个项目,然后调用updateRecord

createRecordsdeleteRecords会相应更改。