I've got some CanJS models roughly arranged like so:
My API sends back user IDs with activities and it looks like CanJS wires up the relationship automatically. Example:
foo = User.new({id: "123"})
and then if
That's neat. But when I do bar.serialize() CanJS tries to serialize the activity, which tries to serialize the user, which descends into the activity again and on and on...
What's the right way to handle these circular relationships when serializing?
- User = can.Model({
- attributes: {
- activities: 'Activity.models',
- }
- });
- Activity = can.Model({
- attributes: {
- user: 'User.model',
- }
- });
My API sends back user IDs with activities and it looks like CanJS wires up the relationship automatically. Example:
foo = User.new({id: "123"})
and then if
- bar = Activity.findOne("456")
- bar.user === foo
That's neat. But when I do bar.serialize() CanJS tries to serialize the activity, which tries to serialize the user, which descends into the activity again and on and on...
What's the right way to handle these circular relationships when serializing?