我想得到没有_id字段的聚合管道的结果.我知道如果你明确提供其他字段作为投影的输出,这是可能的.但是,¿我怎样才能在查找电话中模仿$ projec?
这就是我想要的(没有明确包含的字段):
db.col.find({},{_id:0})
Run Code Online (Sandbox Code Playgroud)
但在聚合框架中似乎是不可能的:
db.col.aggregate([{'$project': {_id:0}}])
Error: Printing Stack Trace
at printStackTrace (src/mongo/shell/utils.js:37:15)
at DBCollection.aggregate (src/mongo/shell/collection.js:927:9)
at (shell):1:11
2013-10-07T16:36:09.273+0200 aggregate failed: {
"errmsg" : "exception: $projection requires at least one output field",
"code" : 16403,
"ok" : 0
} at src/mongo/shell/collection.js:928
Run Code Online (Sandbox Code Playgroud)
有没有想过解决这个问题?