5
可以说我有一个模式,其中包含一个名为preferences的嵌入文档,其中包含多个值。我试图让猫鼬默认嵌入式文档为空如何将默认的嵌入式文档默认为mongoose
例如,这里是我默认的字段在过去像字符串和日期之类的基本类型为null。
var userSchema = new Schema({
name: {type: String, required: true},
preferences: {type: preferences, default: null}
});
var preferences: {
preference1: String,
preference2: String
}
我应该如何将userSchema中的属性首选项设置为在新文档创建时为空?