mongodb mapreduce 出错
发布于 9 年前 作者 wangbinlml 4731 次浏览 最后一次编辑是 8 年前 来自 问答

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 } }

请大神指教!!!

回到顶部