I am using my own mongodb driver for node.js and cannot work with field selection. What I want to do is restrict the fields for the name. I do not want the "last" in the output.
I'm doing it:
db.collection("test").find({},[{'name':true,'last':false}]).toArray(function(err, results) { console.dir(results); });
But the magazine prints:
[ { _id: 524b53588aa4f388de1c2ddb }, { _id: 524b53548aa4f388de1c2dda } ]
So there is no name on the output.
Update : I tried an object instead of an array - it did not work. The reason is that they really mix inclusion and exclusion. You cannot mix it. When I only had "name":true , it worked.
user3111525
source share