How to do field selection on find() in the mongodb native driver?

前端 未结 4 1081
遇见更好的自我
遇见更好的自我 2021-02-19 07:52

I am using the mongodb native driver for node.js and can\'t get to work the field selection. What I want to do is to limit fields to name. I do not want the \'last\' in the outp

4条回答
  •  执笔经年
    2021-02-19 08:23

    Omit the array:

    db.collection("test").find({},{'name':true,'last':false}).toArray(function(err, results) {
        console.dir(results);
    });
    

提交回复
热议问题