On MongoDB 3.4.4 I've created a collection with a validator, but now some inserts fail this rules and I can't understand why.
Thank you!
MongoDB uses a flexible schema model, which means that documents in a collection do not need to have the same fields or data types by default. Once you've established an application schema, you can use schema validation to ensure there are no unintended schema changes or improper data types.
To obtain a list of MongoDB collections, we need to use the Mongo shell command show collections . This command will return all collections created within a MongoDB database.
You can see the validation rules (among other collection information) with db.getCollectionInfos()
for all collections or db.getCollectionInfos({name: "myCollection"})
for a specific collection: MongoDB docs
Have a look at this answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With