猫鼬要求不能在子模式中使用类型

时间:2020-05-28 03:37:59

标签: javascript mongodb mongoose

尝试将子模式标记为必需时出现错误,但是仅当我在子模式中具有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`.

0 个答案:

没有答案