How to retrieve MongoDb collection validator rules?

旧时模样 提交于 2021-02-07 05:24:23

问题


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.

  1. 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...
  2. Is there a way to improve the error message? "Document failed validation" in this scenario is quite useless.

Thank you!


回答1:


  1. 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

  2. Have a look at this answer.



来源:https://stackoverflow.com/questions/45285852/how-to-retrieve-mongodb-collection-validator-rules

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!