sproutcore/sproutcore-datastore — Issue #14: Nested Stores and Nested 
Author: blt04
Created: 2011-10-20 21:23:13+00:00
State: open

I have a simple data structure:

Product = SC.Record.extend {
courses: SC.Record.toMany('Course', {nested: true})
}

I create a nested store:

chainStore = product.get('store').chain();
editProduct = chainStore.find(product);

When I make changes to `editProduct` and call `commitChanges()`, SC produces an error:

oldChildren is undefined

in registerChildToParet at [store.js:1382](https://github.com/sproutcore/sproutcore-datastore/blob/master/packages/sproutcore-datastore/lib/system/store.js#L1382)

If I access one of the courses in the product record using `objectAt` *before* creating the nested store, everything works:

product.get('courses').objectAt(0)
chainStore = product.get('store').chain();
editProduct = chainStore.find(product);

What is the proper procedure for using nested stores on records with nested children?