couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nathan Stott <nrst...@gmail.com>
Subject Re: representing many-to-many relations with concurrent inserts
Date Tue, 01 Dec 2009 04:20:28 GMT
Pete,

You need to write a view that returns more than just LogTopicToLogEntryMap.
 Have it return the topic and entries too and then you can use include_docs
to get it all in one query.



On Mon, Nov 30, 2009 at 5: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. 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
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message