0
我在貓鼬下面的模式,我想有作爲另一個模式的嵌套陣列:定義基於貓鼬架構對象的陣列
var NestedSchema = new Schema({
name: { type: String, required: true }
});
需要和嵌套的陣列的一些其他架構架構。
var EventSchema = new Schema({
name: { type: String, required: true, unique: true },
fields: [NestedSchema]
});
這工作得很好。但是現在我想對該數組運行一些驗證。
var validators = // some validators
var EventSchema = new Schema({
name: { type: String, required: true, unique: true },
fields: [{ type: 'NestedSchema', required: true, validate: validators }]
});
當然類型:'NestedSchema'不起作用,它是在黑暗中拍攝。貓鼬是否允許您根據架構