Closed simonexmachina closed 11 years ago
If I have the following models:
App.Budget = DS.Model.extend accounts: DS.hasMany 'account', async: true App.Account = DS.Model.extend budget: DS.belongsTo 'budget'
And the following document:
{ _id: "a8e57e4af8510a7b6f63c40d37017dc8", accounts: [ "5a3dfebdb35a829cd009b77b4f001567", "5a3dfebdb35a829cd009b77b4f0019fb" ] }
If I call budget.save() before loading the accounts (i.e. budget.get('accounts').then -> budget.save()) then the budget get saved with accounts: [].
budget.save()
budget.get('accounts').then -> budget.save()
accounts: []
budget = @store.find('budget', 'a8e57e4af8510a7b6f63c40d37017dc8').then -> budget.save() # budget gets saved with accounts: []
Workaround is:
budget = @store.find('budget', 'a8e57e4af8510a7b6f63c40d37017dc8').then (budget)-> budget.get('accounts') .then -> budget.save() # budget gets saved with accounts ids
If I have the following models:
And the following document:
If I call
budget.save()
before loading the accounts (i.e.budget.get('accounts').then -> budget.save()
) then the budget get saved withaccounts: []
.Workaround is: