incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Troy Kruthoff <tkruth...@gmail.com>
Subject Re: representing many-to-many relations with concurrent inserts
Date Tue, 15 Dec 2009 07:51:19 GMT
When I first read about this feature I had to take my sql pills to  
calm me down, but then I discovered you do not get the emitting doc as  
well (bummer).

For example, accounts and users as separate docs, a view listing users  
with include_docs would return the user (emitter) and the account (_id  
included in value) doc.  But if I set the view value to the '_id' of  
the account, I get the account.  I know I could store the user in the  
view as well, to get both, but that just fattens up the view.

Better yet would be to allow an array: {'_id',['id1','id2']...}

For now, I've decided to just emit multiple values, example:

         function(doc) {
           if (doc.type=='User') {
             emit([doc.email,doc.password],{'_id':doc.account._id});
             emit([doc.email,doc.password],null);
           }
         }



Troy


On Dec 12, 2009, at 9:55 AM, Jan Lehnardt wrote:

> Hi,
>
> I don't think this has been documented yet. It'd be great if you could
> update the wiki :)
>
> Cheers
> Jan
> --
>
> On 1 Dec 2009, at 11:51, christian schilling wrote:
>
>> thats sounds like a feature i have been waiting for. sadly i can't  
>> find any
>> documentation about this, am i looking in the wrong places (couchdb  
>> wiki) or
>> does is not exist?
>>
>> 2009/12/1 Chris Anderson <jchris@apache.org>
>>
>>> On Tue, Dec 1, 2009 at 8:30 AM, Pete Hodgson <public@thepete.net>  
>>> wrote:
>>>>> 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/
>>>>>
>>>>>
>>>>>
>>>> Hi Chris,
>>>>
>>>> Thanks, I have tried include_docs. As I recall, when I did that  
>>>> couchDB
>>>> included the /mapping document/, not the log entry document. Does  
>>>> that
>>> seem
>>>> feasible? I can go back and confirm the exact results if needed  
>>>> (not at
>>> the
>>>> machine in question ATM).
>>>>
>>>
>>> Yes, the ability to link to non-mapping docs is new in trunk.
>>>
>>>
>>> --
>>> Chris Anderson
>>> http://jchrisa.net
>>> http://couch.io
>>>
>


Mime
View raw message