sample.getCollection()
.find({},{"name":0,_id:0})
.toArray(function(err1,res)
{
if(err1)
return console.log(err1);
console.log(res);
});
我一直试图在Node.js中的MongoDb的查找查询中隐藏字段,但Projection部分无法按预期工作。在查询中都没有显示任何错误。它显示了所有文档中的所有可用字段。
find({},{"name":0,_id:0})
是本机mongodb语法。
试试这样的事情-
sample.getCollection()
.find({}).project({"name":0,_id:0})
.toArray(function(err1,res)
{
if(err1)
return console.log(err1);
console.log(res);
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句