Second parameter to limit fields in find() not working in Mongodb

前端 未结 3 741
遇见更好的自我
遇见更好的自我 2020-12-20 06:42

Mongodb Database view

I want to omit the _id field in my result

MongoClient.connect(\"mongodb://localhost:27017/\",function(err,client)         


        
3条回答
  •  天命终不由人
    2020-12-20 07:37

    This should work. Using the boolean "false".

    MongoClient.connect("mongodb://localhost:27017/",function(err,client){ var db = client.db("customerDetails"); db.collection("customerName").find({},{ _id : false}).toArray(function(error,result){ console.log(result); client.close(); }); });
    

提交回复
热议问题