【发布时间】:2020-07-07 15:20:44
【问题描述】:
在 mongo db compass 上,我想使用验证模式,但我的属性中有一个是枚举,取决于这个字段,另一个字段可以切换我可以使用 JSON 模式来做到这一点,但它似乎没有为什么要在 mongoDB compass 上工作?
{
type: 'object',
properties: {
type: {
enum: ['teacher', 'student']
},
firstname: {
type: 'string',
},
lastname: {
type: 'string',
},
login: {
type: 'string',
},
pwd: {
type: 'string'
},
"if": {"properties": {"type": {"const": "student"}}},
"then": {"properties": {classes: {type: "array"}}}
},
required: [
'type',
'firstname',
'lastname',
'login',
'pwd',
],
};
【问题讨论】:
标签: mongodb json-schema-validator mongodb-compass