尝试将子模式标记为必需时出现错误,但是仅当我在子模式中具有type
属性时才会发生错误。这是一个示例:
const UserSchema = new mongoose.Schema({
created: {
type: Date,
default: Date.now,
},
subscription: {
required: true,
type: {
type: { type: String },
renews: Date,
},
},
});
那扔...
TypeError: Invalid schema configuration: `True` is not a valid type at path `subscription.required`.