One can easily manage existance of some fields in db.find()
's result set by specifying fields
parameter (I use Meteor and test all queries on server side, in publishing function). Say Meteor.collection.find({}, { fields: { 'a': false } })
tells Mongo to exclude field a
from the result set.
However, if a
is a subdocument, this doesn't work. Say, it has two fields: x
and y
. If I specify { 'a.x': false }
, one of these fields is excluded, but not the other. If I add { 'a': false}
, nothing happens.
Here is the question: is there any way to filter out from result set all fields that lie in some particular subdocuments of a document?