5
回滾父記錄似乎不會刪除可能已添加到其中的任何新子記錄。不確定這是一個錯誤還是功能。回滾父記錄不會刪除子記錄
App.Company = DS.Model.extend({
name: DS.attr('string'),
employees: DS.hasMany('App.Employee')
});
App.Employee = DS.Model.extend({
name: DS.attr('string'),
company: DS.belongsTo('App.Company')
})
var company = App.Company.find(1);
//Initially: company.get('employees.length') => 0
var employee = company.get('employees').createRecord();
//Now: company.get('employees.length') => 1
employee.get('transaction').rollback();
//Still: company.get('employees.length') =>1
//Also: employee.get('isDeleted') => true
company.get('transaction').rollback();
//Even now: company.get('employees.length') =>1
//How do I rollback such that company.get('employees.length') == 0