这是我的用户架构:
var userSchema = mongoose.Schema({
profile: {
username: { type: String, required: true, unique: true },
role: String
},
auth: {
hashedPassword: { type: String, required: true },
facebookToken: String,
twitterToken: String,
googleToken: String
},
});
我想为整个select = false
对象设置auth
。我该怎么做?
答案 0 :(得分:4)
只需这样添加:
var userSchema = mongoose.Schema({
profile: {
username: { type: String, required: true, unique: true },
role: String
},
auth: {
type : {
hashedPassword: { type: String, required: true },
facebookToken: String,
twitterToken: String,
googleToken: String
},
select: false //<---- added here
}
});