问题
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.
- Is there a way to output the rules of the validor? I'm afraid the rules applied are different from what I think they are...
- Is there a way to improve the error message? "Document failed validation" in this scenario is quite useless.
Thank you!
回答1:
You can see the validation rules (among other collection information) with
db.getCollectionInfos()for all collections ordb.getCollectionInfos({name: "myCollection"})for a specific collection: MongoDB docsHave a look at this answer.
来源:https://stackoverflow.com/questions/45285852/how-to-retrieve-mongodb-collection-validator-rules