In fact, an example of what you are trying to do:
var map = function() { emit(this.product_id, {"_id" : this._id, "name" : this.name }); } var finailise = function(key, value){ return value[0];
However, note that there are two types of different ones:
There is no standard way for different ones, and each database has its own methods, it is not even standard for SQL databases, so you need to know which way you want to distinguish. The above first detects the difference. You can make the latest discovery great, like:
var finailise = function(key, value){ return value[value.length-1]; }
Or something like that, you must have started anyway.
Hope this helps,
source share