Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I delete the validation rule appiled to my collection?

Tags:

mongodb

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 ?

like image 512
molecule Avatar asked Jan 04 '17 07:01

molecule


People also ask

How do I remove a validation rule?

To remove a certain data validation rule, select any cell with that rule, open the Data Validation dialog window, check the Apply these changes to all other cells with the same settings box, and then click the Clear All button.

Can you delete a validation rule in Salesforce?

It's possible to activate or deactivate validation rules before migration to Salesforce on both Salesforce Classic and Lightning Experience platforms. Note: Available in Essentials, Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, Developer, and Database.com Editions.

How do you delete a validation in SAP?

Select the node of the required validation. The Change Validation: <Validation Name> (Header data) screen appears. Choose Validation Delete . A dialog box appears, asking if you want to delete the validation.


1 Answers

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

like image 153
felix Avatar answered Oct 24 '22 15:10

felix