How to exclude one particular field from a collection in Mongoose?

前端 未结 6 2152
逝去的感伤
逝去的感伤 2020-12-13 12:15

I have a NodeJS application with Mongoose ODM(Mongoose 3.3.1). I want to retrieve all fields except 1 from my collection.For Example: I have a collection Pr

6条回答
  •  温柔的废话
    2020-12-13 12:40

    Model.findOne({ _id: Your Id}, { password: 0, name: 0 }, function(err, user){
      // put your code
    });
    

    this code worked in my project. Thanks!! have a nice day.

提交回复
热议问题