-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
linked documents feature (feature request) #6
Comments
I'm not sure how you would use it. We use the views to load associations on demand, e.g. user.comments will load all comment objects and comment.user will load the user to this comment. IMHO using the _id feature would allow you to load the user while you are loading the comment, similar to the :include feature of ActiveRecord. But this would only work for objects that use "belongs_to" to load the master object too. Am I missing something? |
it's the on-demand that's both good and bad. it's good in scenarios where you don't frequently need it, but costly if you're displaying a list. picture a person with an address. if i load a list of people, and then display their home addresses, a list of n people will result in n+1 calls to the server. given the option to say "eager-load the belongs_to", that can come back down to 1. |
Yes, but it only works for the belongs_to, so in your example probably the person has_one address and the address belongs_to a person. If you display a list of persons this wouldn't work, only if you display a list of addresses. The real solution is to have a custom view or even store the address on the person. But I can see how much trouble it would to add it to blongs_to. I'm only afraid that it will confuse people as it only works for belongs_to and not has_one/many as it does in SQL. CouchDB is different :-) |
yeah - i got it backwards, but the scenario still holds |
since .11, couchdb supports the notion of linked documents (emitting _id). it would be beneficial if the default views would leverage this to fetch associated documents
The text was updated successfully, but these errors were encountered: