couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Anderson <jch...@apache.org>
Subject Re: representing many-to-many relations with concurrent inserts
Date Tue, 01 Dec 2009 06:59:40 GMT
On Mon, Nov 30, 2009 at 3:05 PM, Pete Hodgson <public@thepete.net> wrote:
> Roger, please accept my apologies. I'll be sure to not cross-post on this
> list again. Nathan, thanks for the link. That's a very helpful post.
>
> So do I take it from that post that creating a mapping document like I
> described below is the Right Way to deal with concurrent update concerns?
> Also, is there any way to formulate a view into a many-to-many relationship
> which allows include_docs to work correctly? The view I have to retrieve all
> log entries matching a log topic currently looks something like:
>
> function(doc) {
>      if( doc['couchrest-type'] != 'LogTopicToLogEntryMap' )
>        return;
>
>      emit(doc['topic_id'], doc['entry_id']);
>    }
>
> This works, but I have to manually pull out the entry_id array in the client
> and then use it to do a second view query to get the actual log entries.

Have you looked at the include_docs=true view query parameter? With
CouchDB 0.11 you can emit {"_id":"foo"} to include docs that aren't
the one that did the emiting.

This technique is used in http://aimpl.org/


> I
> could create a view which contains the log entry document itself, but I'm
> concerned about the amount of data duplication this would cause, given that
> log entries will be the most common document by far in the system.
>
> Cheers,
> Pete
>



-- 
Chris Anderson
http://jchrisa.net
http://couch.io

Mime
View raw message