|
compass version 1.20.5
When I enter the following into compass, I get a parsing error saying unexpected token ':'
$jsonSchema: {
|
{
|
bsonType: "object",
|
required: ["name"],
|
properties: {
|
name: {
|
bsonType: "string",
|
description: "must be a string and is required"
|
}
|
}
|
}
|
}
|
When I enter the following it saves the validator but the validator doesn't work because it doesn't have $jsonSchema notation.
{
|
bsonType: "object",
|
required: ["name"],
|
properties: {
|
name: {
|
bsonType: "string",
|
description: "must be a string and is required"
|
}
|
}
|
}
|
MongoDB Enterprise SHARED-DEMO-shard-0:PRIMARY> db.getCollectionInfos()
|
[
|
{
|
"name" : "schema_validation",
|
"type" : "collection",
|
"options" : {
|
"validator" : {
|
"bsonType" : "object",
|
"required" : [
|
"name"
|
],
|
"properties" : {
|
"name" : {
|
"bsonType" : "string",
|
"description" : "must be a string and is required"
|
}
|
}
|
},
|
"validationLevel" : "strict",
|
"validationAction" : "error"
|
},
|
"info" : {
|
"readOnly" : false,
|
"uuid" : UUID("7ff90c0b-0569-4974-8dff-d442d6bab910")
|
},
|
"idIndex" : {
|
"v" : 2,
|
"key" : {
|
"_id" : 1
|
},
|
"name" : "_id_",
|
"ns" : "kang.schema_validation"
|
}
|
},
|
When I manually create the collection using mdb clu with jsonSchema notation for the validator, it works.
|