【发布时间】:2017-08-18 18:34:29
【问题描述】:
我一直在本地构建我的应用程序,一切正常,它使用最新的 MongoDB 3.4,我的聚合调用工作正常。
app.get('/random_menu', function (req, res) {
Menus.aggregate([{$sample: {size: 1}}], function (err, data) {
res.json(data);
});
});
我现在已将我的代码移动到仅限于 MongoDB 2.4.10 的树莓派上,我的聚合函数似乎无法在它上面运行。我的应用没有返回任何数据,也没有错误。
为了测试,我通过 RoboMongo 进行了测试,如下所示,在本地 3.4 版本上运行良好:
db.getCollection('menus').aggregate([{$sample: {size: 1}}])
但是当我通过 RoboMongo 在 pi db 上尝试时,我收到以下错误:
assert: command failed: {
"errmsg" : "Pipeline::parseCommand(): unrecognized field \"cursor",
"ok" : 0
} : aggregate failed
_getErrorWithCode@src/mongo/shell/utils.js:23:13
doassert@src/mongo/shell/assert.js:13:14
assert.commandWorked@src/mongo/shell/assert.js:266:5
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1215:5
@(shell):1:1
Error: command failed: {
"errmsg" : "Pipeline::parseCommand(): unrecognized field \"cursor",
"ok" : 0
} : aggregate failed :
_getErrorWithCode@src/mongo/shell/utils.js:23:13
doassert@src/mongo/shell/assert.js:13:14
assert.commandWorked@src/mongo/shell/assert.js:266:5
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1215:5
@(shell):1:1
我试过用谷歌搜索,但似乎找不到任何东西。我对 MongoDB 比较陌生,因此非常感谢任何输入。
【问题讨论】:
标签: node.js mongodb raspberry-pi robo3t