incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul Carey" <>
Subject Re: when to use another document and when not to?
Date Sun, 27 Jul 2008 17:18:58 GMT
>> If I can summarise the options - please feel free to correct me here! - :

>> 2. Store the membership in the followed object (in an array)
>> 3. Store the membership in the following user

> I would *like* to place subscriptions in one or the other but just cannot
> think of how it is possible to write the views *in both directions* once
> it's stuck in a user, and I end up having to do the GET loop anyway.

At the risk of misunderstanding / stating the obvious, there's nothing
to stop you doing both 2 and 3 and eliminating the n+1 query loop.
Each user can maintain an array of both those he follows and those who
follow him. You could update both follower and leader in a bulk
transaction to ensure consistency.

I've created a simple example. I used photos and tags instead of
followers because I find the self referentiality of the follower model
adds unnecessary confusion, but the underlying concept - a many to
many relationship - remains.



View raw message