将从下面的 js 文件创建一个集合,我的集合中需要三个字段,所以我给出了
emit(this.cust_id, 1,date);
它给出了以下错误
地图调用失败:JS 错误:错误:fast_emit 需要 2 个参数(匿名):1
但它的工作正常emit(this.cust_id, 1);
请告诉我如何在创建的集合中包含日期??
m = function() {
var currentDate = new Date();
currentDate.setDate(currentDate.getDate()-1);
var month = (currentDate.getMonth() < 9 ? "0"+ (currentDate.getMonth()+1) : (currentDate.getMonth()+1));
var day = (currentDate.getDate() < 10 ? "0" + currentDate.getDate() : currentDate.getDate());
var date = currentDate.getTime();
emit(this.cust_id, 1,date);
}
r = function (k, vals) { var sum = 0; for (var i in vals) { sum += vals[i]; } return sum; }
q = function() {
var currentDate = new Date();
currentDate.setDate(currentDate.getDate()-1);
var month = (currentDate.getMonth() < 9 ? "0"+ (currentDate.getMonth()+1) : (currentDate.getMonth()+1));
var day = (currentDate.getDate() < 10 ? "0" + currentDate.getDate() : currentDate.getDate());
var date = currentDate.getTime();
var patt = date;
var query = {"created_at":"2013-30-04 11:19:52.587"};
return query;
}
res = db.logins.mapReduce(m, r, { query : q(), out : "LoginCount" });