sproutcore / guides

The guides source. Build and push to https://github.com/sproutcore-guides/sproutcore-guides.github.com.

Home Page:http://guides.sproutcore.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Records guide is unclear on how to use the toMany relation properly

SpacyRicochet opened this issue · comments

The Records guide (http://guides.sproutcore.com/records.html) is very clear on how to create the different types of relations, such as one-to-many. However, while trying to unit test such a relation by creating and pushing an object, I found out that the guide is wholly inadequate in explaining how you would use objects stored a toMany relation.

The following gist (https://gist.github.com/1276759) shows the frustration I had. The guide doesn't clearly mention that you have to set an ID first, before any relation with an object can make sense and the object is able to be used again through that relation. Also, a little note that ManyArrays won't work with the bracketed index (ie. testObject.get('toManyObjects')[0]), but only with objectAt() is worth mentioning.

This is something that might be obvious to those more used to databases, but not to those that are new to the concept.