sproutcore/sproutguides — Issue #102: Records guide is unclear on how to use the toMany relation properly
Author: SpacyRicochet
Created: 2011-10-10 23:03:34+00:00
State: open

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.