How to remove only one or two fields from documents in mongodb?
aggregation-framework, mongodb, mongodb-query
Solution
You need to explicitly include fields when using aggregation either via various pipeline operations or via `$project`. There currently isn't a way to return all fields unless explicitly defined by field name:
$project : {
_id : 0,
"Name" : 1,
"Address" : 1
}
You can exclude the `_id` using the technique you used and as shown above.
Problem
This is a very easy question, just having a really bad brain freeze. In my aggregation, I just want to remove the '_id' field by using `$project` but return everything else. However, I'm getting $projection requires at least one output field I would think it's like : ``` db.coll.aggregate( [ { $match .... }, { $project: { _id: 0 }}]) ```