Skip to content

Instantly share code, notes, and snippets.

@danared
Created October 29, 2015 20:09
Show Gist options
  • Save danared/c5dccf86b92cdd2b8414 to your computer and use it in GitHub Desktop.
Save danared/c5dccf86b92cdd2b8414 to your computer and use it in GitHub Desktop.
db.orders.runCommand("collMod",
{validationLevel: "moderate",
validationAction: "error"});
db.runCommand({collMod: "orders",
validator: {
price: {$exists: true},
price: {$type: 1}
}
});
```
The validation rules for this collection can now be checked:
```javascript
db.getCollectionInfos({name:"orders"})
[
{
"name": "orders",
"options": {
"validator": {
"price": {
"$type": 1
}
},
"validationLevel": "moderate",
"validationAction": "error"
}
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment