javascript - String becomes undefined in mapReduce -


i trying count number of docs per day in collection. using mongodb mapreduce function following map , reduce functions:

var tsmapper = function(){     // timestamp , convert date     var ts = new date((this.ntimestamp_ms));     var months = ['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'];     var year = ts.getfullyear();     var month = months[ts.getmonth()];     var date = ts.getdate();     var newts = month + ' ' + date + ' ' + year;     // emit newts , value 1     emit(string(newts), 1);    } 

and reducer function:

var reducer = function(key,values){     return array.sum(values);     } 

then when run code on database:

db.test.mapreduce(tsmapper, reducer, {"out" : "ts_count"}) 

it returns collection 1 document in "_id" of "undefined nan nan" , value equal total number of documents:

{ "_id" : "undefined nan nan", "value" : 6 } 

could please let me know why newts string becoming "undefined nan nan"?


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -