说我有一个架构
var userSchema = new mongoose.Schema({
email: 'string',
password: 'string,
age: {type: 'number', select: false}
})
User.find({...}).exec().then(function(user){
//user.age -> is undefined
...
// LATER I want "age" to be filled from DB
//So I may do (I may also wrap in custom model method)
User.findById(user._id, 'age').exec().then(function(userOnlyAge){
user.age = userOnlyAge.age
..
})
})
最好的方法是什么?我想知道它是否可以开箱即用?