4

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?

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

No, I don't want to bootstrap data rendered inside the page. I'm looking for a purely client side solution to the problem.
No bootstrap needed. When you fetch the data you can have your backend return whatever including the dependent objects

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.