Show
In the MongoDB shell:
test> db.version()
3.5.12-380-g168f195001
test> db.test.insert([{x:1},{x:2},{x:3}]);
Try aggregating without the cursor document:
test> db.runCommand({aggregate: "test", pipeline: []})
{
"operationTime" : Timestamp(1507216222, 1),
"ok" : 0,
"errmsg" : "The 'cursor' option is required, except for aggregate with the explain argument",
"code" : 9,
"codeName" : "FailedToParse"
}
Now with the cursor document:
test> db.runCommand({aggregate: "test", pipeline: [], cursor:{}})
{
"cursor" : {
"firstBatch" : [
{
"_id" : ObjectId("59d64b3c374bbed61ea8ba4a"),
"x" : 1
},
{
"_id" : ObjectId("59d64b3c374bbed61ea8ba4b"),
"x" : 2
},
{
"_id" : ObjectId("59d64b3c374bbed61ea8ba4c"),
"x" : 3
}
],
"id" : NumberLong(0),
"ns" : "test.test"
},
"ok" : 1,
"operationTime" : Timestamp(1507216252, 1)
}
But it behaves the same as passing explain:false
test> db.runCommand({aggregate: "test", pipeline: [], explain:false})
{
"cursor" : {
"firstBatch" : [
{
"_id" : ObjectId("59d64b3c374bbed61ea8ba4a"),
"x" : 1
},
{
"_id" : ObjectId("59d64b3c374bbed61ea8ba4b"),
"x" : 2
},
{
"_id" : ObjectId("59d64b3c374bbed61ea8ba4c"),
"x" : 3
}
],
"id" : NumberLong(0),
"ns" : "test.test"
},
"ok" : 1,
"operationTime" : Timestamp(1507216292, 1)
}