📌  相关文章
📜  Mongoose 需要对象 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:57.350000             🧑  作者: Mango

代码示例1
const extraDataSchema = new mongoose.Schema({
  brand: {
    type: String,
    required: true,
    minlength: 1,
    maxlength: 255
  },
  quantity: {
    type: Number,
    required: true,
    minlength: 1,
    maxlength: 10
  }
});

const productSchema = new mongoose.Schema({
  name: {
    type: String,
    required: true,
    minlength: 1,
    maxlength: 255
  },
  extraData: {
    type: extraDataSchema, required: true
  }
});