Here below show my code. I have to calculate the how many times distinct value repeated. Here i have store distinct value in "results".I used collection.count() to calculate but it's not work. please any one tell me where i have to mistake. Thank you very much .
var DistinctIntoSingleDB = function(Collection,arr,opt,distVal,callback){
Collection.find({}).distinct(distVal, function(err, results) {
if(!err && results){
console.log("Distinct Row Length :", results.length);
var a,arr1 = [];
for(var j=0; j<results.length; j++){
collection.count({'V6': results[j]}, function(err, count) {
console.log(count)
});
arr1.push(results[j]+ " : " +a);
}
callback(results,arr1);
}else{
console.log(err, results);
callback(results);
}
});
See Question&Answers more detail:os