I have multiple CouchDB documents representing a timestamp with a property userId and tag (a user can have n timestamps and assign each one a tag). I want to query CouchDB b
Answering my own question.
Seems like CouchDB supports arrays as keys. With that in mind it's pretty simple:
Map:
function(doc) { if(doc.tag) emit([doc.userId, doc.tag], 1); }
Reduce:
function(keys, values) { return sum(values); }
The result is then sorted by userId & tag.