You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Paul Barry <ma...@paulbarry.com> on 2008/10/01 06:16:02 UTC
Handling many-to-many type queries
Say I have 2 document types, User and Group. A user can be in many groups
and a Group can have many users. So I store an array of group ids in each
user document. Is there a way to write a view that returns all of the group
documents for a given user?
Re: Handling many-to-many type queries
Posted by Chris Anderson <jc...@apache.org>.
On Tue, Sep 30, 2008 at 9:16 PM, Paul Barry <ma...@paulbarry.com> wrote:
> Say I have 2 document types, User and Group. A user can be in many groups
> and a Group can have many users. So I store an array of group ids in each
> user document. Is there a way to write a view that returns all of the group
> documents for a given user?
>
Not really - unless a user has tens of thousands of groups, I'd just
use GET requests to load each group document individually.
And/Or you could store the user_ids in the Group documents, and then
it'd be easy to emit them into a view from the group document.
Don't underestimate the power of requesting multiple docs (as long as
they are smallish).
There will be a feature added soon which allows you to fetch multi
docs in one request.
--
Chris Anderson
http://jchris.mfdz.com