Mongoose是否支持选择属性的模式?

时间:2015-06-01 15:08:08

标签: mongoose schema

是否可以使用包含必须包含多个子文档模式之一的属性的Schema?

var childSchema1 = new Schema({ name: 'string' });
var childSchema2 = new Schema({ age: 'number' });

var parentSchema = new Schema({
  // i.e child must be either childSchema1 or childSchema2
  child: [childSchema1, childSchema2]
})

0 个答案:

没有答案