저는 최신 MongoDB 3.4를 사용하며 모든 집계 호출이 잘 작동하는 모든 응용 프로그램을 로컬로 구축하고 있습니다. MongoDb 집합체에 오류가 발생했습니다.
app.get('/random_menu', function (req, res) {
Menus.aggregate([{$sample: {size: 1}}], function (err, data) {
res.json(data);
});
});
는 지금 MongoDB를 2.4.10로 제한됩니다 내 라즈베리 파이에 내 코드를 이동하고 내 집계 함수가 작동하지 않습니다 보인다. 내 앱에서 데이터를 반환하지 않으며 오류가 없습니다.
내가 로컬 3.4 버전에서 잘 작동 다음으로, RoboMongo를 통해 그것을 시도 테스트하려면 :
db.getCollection('menus').aggregate([{$sample: {size: 1}}])
을하지만 RoboMongo를 통해 파이 DB에 그것을 시도 할 때, 나는 다음과 같은 오류가 발생합니다 :
assert: command failed: {
"errmsg" : "Pipeline::parseCommand(): unrecognized field \"cursor",
"ok" : 0
} : aggregate failed
[email protected]/mongo/shell/utils.js:23:13
[email protected]/mongo/shell/assert.js:13:14
[email protected]/mongo/shell/assert.js:266:5
[email protected]/mongo/shell/collection.js:1215:5
@(shell):1:1
Error: command failed: {
"errmsg" : "Pipeline::parseCommand(): unrecognized field \"cursor",
"ok" : 0
} : aggregate failed :
[email protected]/mongo/shell/utils.js:23:13
[email protected]/mongo/shell/assert.js:13:14
[email protected]/mongo/shell/assert.js:266:5
[email protected]/mongo/shell/collection.js:1215:5
@(shell):1:1
나는 이것을 검색해 봤지만 아무것도 찾을 수 없습니다. 필자는 MongoDB를 새롭게 접하기 때문에 모든 입력을 크게 높이 평가할 것입니다.
철저한 설명과 조언을 주신 @Stennie에게 감사드립니다. – Andrew