sinisterchipmunk/jax — Issue #41: Model Relations
Author: sinisterchipmunk
Created: 2011-12-11 21:00:22+00:00
State: open
Labels: enhancement

Currently, if a model is associated with another model, data must be parsed explicitly:

new SolarSystem(planets: [ { name: "mercury" }, {name: "venus" }, ... ])
// within SolarSystem#after_initialize:
for (var i = 0; i < this.planets.length; i++)
this.planets[i] = new Planet(this.planets[i]);

It would be very helpful to establish ActiveRecord-like relations for models. Example JS:

SolarSystem.has_many "planets"
SolarSystem.has_many "planets", model_name: "Planet"
// etc.

This way, Jax could automatically convert an associated model's data into its corresponding instance.