couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wout Mertens <>
Subject Re: Mapping a Relation and include_docs
Date Sun, 19 Apr 2009 16:45:48 GMT
Hi Thomas,

Did you read for  
ideas? I think you'll find that in your case you'd just want to embed  
the list of groups that a users is a member of...

> The THIRD argument to emit would change the associated id to the  
> user_id so
> when fetchting /group_members?include_docs=true&key=idofgroup it would
> return the user doc instead of the membership doc. This of course is  
> a pure
> optimization since I can just emit the user_id, fetch those and then  
> do a
> second request to _all_docs with keys=[id1,id2,...].

Hmmm... I don't know how CouchDB gets those source document IDs. I  
suppose it would be nice to be able to say include_docs=field:userid  
so CouchDB would return the document with the ID equal to the value of  
the userid field.

I'm interested in what the devs think of this... Devs?

> The only Problem I have with my implementation is that a user is never
> allowed to edit his own membership, only a group admin is allowed to  
> do
> that. So I have 2 different people editing the same Document and  
> somehow
> that feels dirty.

But wouldn't a validation function be able to test for exactly these  
situations? If the change is proposed by a user then these fields are  
allowed to change, if a group admin then these fields...

I suppose programming is a bit different from just saying "you have  
read-only access to this column" so I can understand your hesitation.  
Triple-check your validation functions I would say :)


View raw message