couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Heiko Henning <>
Subject Re: map reduca with object as key
Date Thu, 18 Aug 2011 05:13:41 GMT
Thanks for antswer,  it work.

Why store and get  only work with array, but not with object?
Ok i have now a solution but it think it's odd.


emit([doc.lom_id, doc.user], doc.value);
emit([doc.lom_id, 'all'],    doc.value);
/testdb/_design/rating/_view/get_rating?group=true&key=[1337, "all"]

*Dont work:*

emit({lom_id:doc.lom_id, user:doc.user}, doc.value);
emit({lom_id:doc.lom_id, user:'all'},    doc.value);

key = {"lom_id":"1337","user":"all"}

Regards Heiko

Am 17.08.2011 18:40, schrieb Jens Alfke:
> On Aug 17, 2011, at 12:09 AM, Heiko Henning wrote:
> Is there a possibility to have key as Object?
> Or have i to do thinks like:
> emit(doc.lom_id+'___'+user:doc.user, doc.value);
> emit(doc.lom_id+'___all', doc.value);
> Usually people use arrays, not objects, as composite keys. Keys are sorted, after all,
and it’s kind of unclear how to sort objects since the key-value pairs have no intrinsic
> So try something like emit([doc.lom_id, user:doc.user], doc.value);
> —Jens

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