O'Reilly logo

SproutCore Web Application Development by Tyler Keating

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Defining record relationships

This brings us to the last type of attribute we will use: the relationship attribute. Records are often related to each other as one-to-one, one-to-many, or many-to-many and we can encode this hierarchy in our SproutCore data model as well. To indicate a relationship, we use one of either SC.SingleAttribute (that is, to one) or SC.ManyAttribute (that is, to many), which is done just like we did with SC.RecordAttribute by using SC.Record helper methods. In this case, the helpers are toOne and toMany to be exact.

For example, if you recall from our simple data model example of Calendar and Event records, we indicated a relationship between the two. This relationship will exist in the raw data on the server, such that ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required