Mongoose use of .select() method

前端 未结 9 1659
孤城傲影
孤城傲影 2020-12-14 14:16

I\'m pretty confused with the use of the select method. This is how I use it, and it\'s wrong:

Transaction.find({username : user.username}).sele         


        
9条回答
  •  旧时难觅i
    2020-12-14 14:59

    This was pretty helpful: How to protect the password field in Mongoose/MongoDB so it won't return in a query when I populate collections?

    Looks like you have a few options.

    1) Use select('-_id'). 2) Use find({whatever: values}, '-_id', callback...}. I can't verify this method, but if it works with select(), I don't see why it wouldn't work here.

提交回复
热议问题