|
The command
db.example.aggregate([{$project: {_id: 0}}])
|
fails because "$project requires at least one output field." Now that $project supports exclusion of other fields, it would be nice if it supports exclusion of just the _id field.
Interestingly, I can enforce "exclusion mode" by projecting out a field that doesn't exist:
> db.example.find()
|
{ "_id" : ObjectId("576d9dc03fcfa43a8b713c74"), "a" : { "a1" : 5, "a2" : 6 }}
|
{ "_id" : ObjectId("57716feaf6545b026b3dfca1"), "a" : { "a1" : 3, "a2" : 7 }}
|
> db.example.aggregate([{$project: {_id: 0, c: 0} }])
|
{"a" : {"a1":5, "a2":6 } , "b":4 }
|
{"a" : {"a1":3, "a2":7 }}
|
|