Hi,
why do you say it is a 'mistake' to emit doc from a view?
I do have views that get some param and return the resulting doc(s).
E.g.:
|||"|map|":|"function(doc) {if(doc.startDate && !doc.disabled) {emit(doc.startDate,
doc);}}"||||
Is there more effective way?
Thanks.
------------------------------------------------------------------------
*With best regards,*
Kiril Stankov
On 2/1/2015 4:30 PM, Jonas Weber wrote:
It is a common "mistake" to emit a document or document id from a
view; if it is not mirroring your _id, please ignore my last comment.
On February 1, 2015, Ayhan Kesenci <[email protected]> wrote:
what do you mean, with id_str ?, but it is in the same datafile !
2015-02-01 14:59 GMT+01:00 Jonas Weber <[email protected]
<mailto:[email protected]>>:
Because emit() takes two parameters, one is the key, one is the
value.
However, you can emit arrays as key and/or as value, and they will be
sorted as expected:
emit([doc.user.friends_count, doc.user.followers_count], doc.id_str);
Or something similar...
By the way, what is id_str? If you want to use the doc when
requesting the
view, it is better to request the document directly with
?include_docs=true, saving you a roundtrip to the server.
On February 1, 2015, Ayhan Kesenci <[email protected]
<mailto:[email protected]>> wrote:
Why it is not possible to create a view like this
function(doc) {
emit(doc.user.friends_count,doc.user.followers_count,doc.id_str);
}
??