projection not working with db.collection.find in mongo [duplicate]

丶灬走出姿态 提交于 2019-12-01 03:03:56

you could separate projection like this:

    parrots.find({
        age: { $gt: +process.argv[2] }
    }).project({_id:0}).toArray(function(err, docs){
        if(err) throw err;
        console.log(docs);
        database.close();
    });

i had the same issue with being unable to get projection to work, and the above method worked for me

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!