I am new to mongodb and I am trying out the document validators that the database itself provides. Here is the command that I have written
db.runCommand({
collMod: "admin",
validator: {
$or : [
{ isActive : { $type : "bool" }},
],
$and: [
{ name : { $type : "string" }},
{ mobileNumber : { $type : "int" }},
]
},
validationAction: "error",
validationLevel: "strict"
});
So it executed perfectly and I can see it in getCollectionInfo command but now I want to delete this rule but I can't find the method to do it anywhere.
How do I delete this ? Also is there any method which can apply validators to collection which exists as well as non existing collections ?
You should be able to do this by setting the validation level to off
db.runCommand({
collMod: "admin",
validator: {},
validationLevel: "off"
})
Where collMod is the name of your collection