the document in my mongo collection like this:
{
"_id" : ObjectId("568f7e67676b4ddf133999e8"),
"auth_dic" : {
"2406" : [
"44735"
],
"6410" : [
"223423"
]
...
...
},
"user_id" : "fdasd23423"
}
this is one user, there are many id like '2406' '6410' in 'auth_dic'
i want to user map_reduce method to statistic how many users have the '2406', how many users have the '6410', and other types. my mapper is:
mapper = Code('''
function(){
this.auth_dic.forEach(function(app_id){
emit(app_id, 1);
});
}
''')
my reducer is:
reducer = Code('''
function(key, values){
var total = 0;
for (var i = 0; i < values.length; i++) {
total += values[i];
}
return total;
}
''')
but the mapper can not work, beacause the function 'forEach' can not user to iterate a dic, what can i do to solve this problem?