以过滤掉password字段为例
    1. password:0

    1. User.findOne({username, password: md5(password)}, {password:0}, function (err, user)
    2. {
    3. //处理逻辑
    4. })

    2. select:false
    直接在定义schema规则的时候就规定查询的时候不返回password

    1. var userSchema = new mongoose.Schema({
    2. username: {
    3. type:String,
    4. required:true,
    5. minlength:2,
    6. maxlength:20
    7. },
    8. password: {
    9. type:String,
    10. required:true,
    11. select:false
    12. },
    13. })