I don't usually want or need the "_id" field to be returned in my queries. So, for each query, I have to set:
{ $projection: "_id": 0 }
Is it possible to set this value globally so that any query executed will not include the "_id" field?
I don't usually want or need the "_id" field to be returned in my queries. So, for each query, I have to set:
{ $projection: "_id": 0 }
Is it possible to set this value globally so that any query executed will not include the "_id" field?
In MongoDB you can't use any global projection if you don't want a _id field you can set {_id:0}
in projection. If you use aggregation you can project {"$project" : {"_id" : 0,...}}
your fields in an initial pipeline stage. because MongoDB every pipeline input is depending on the previous pipeline out.
aggregation pipeline stages , $project