CNode

mongodb mapreduce 出错

问答
Wwangbinlml发布于11 年前最后回复11 年前0 回复5025 浏览0 收藏

var map = function () { var key = { user_id: this.user_id }; emit(key, this.score); }; var reduce = function (key, values) { var total = 0; for (var i = 0; i < values.length; i++) { total += values[i]; } return total; }; var options = { query: {created_at:'2015-08-09'}, out: { replace: 'tempCollection' }, jsMode: true, verbose: true };

var collection = dbs.collection("posts"); collection.mapReduce(map, reduce, options, function (error, outCollection) { if (error) { console.error(error); } else { outCollection.find().toArray(function (err, result) { callback(err, result); }); } });

错误信息:

{ [MongoError: ns doesn't exist] name: 'MongoError', message: 'ns doesn't exist', ok: 0, errmsg: 'ns doesn't exist', '$gleStats': { lastOpTime: { bsontype: 'Timestamp', low: 0, high_: 0 }, electionId: 55dffcc1b4f2f3db192d8a52 } }

请大神指教!!!

查看回复

回复 (0)

暂无回复,成为第一个参与讨论的人。
参与回复
登录后即可参与回复。登录