I have a model which has 2 nested collections. What's 开发者_如何转开发the best way of automatically fetching those collections when I "fetch" the parent model?
In Rails you can include the dependant objects in your JSON. I do not know the backend you are using, but this would save you a couple round trips:
{
att1: val,
col1: [{obj1: val}, {...}],
col2: [{...}]
}
Otherwise, override the initialize of Model to create and fetch the 2 new dependent collections.
精彩评论