Couchbase - returns single values

I have a list of small JSON documents in the format:

{ "name":"Kate", "event":"read" }, { "name":"Jon", "event":"delete" },... 

My map function is as follows:

 function(doc, meta){ emit(doc.event, null); } 

As a result, I get a list of all events, including duplicates. How to reduce the result set to individual values ​​only?

thanks

+1
source share
1 answer

This is the answer to another question, modified in accordance with this question. I hope this helps someone! Reduction Function:

 function(keys, values, rereduce) { return keys.filter(function (e, i, arr) { return arr.lastIndexOf(e) === i; }); } 
0
source

Source: https://habr.com/ru/post/990064/


All Articles