如何检索 MongoDb 集合验证器规则? [英] How to retrieve MongoDb collection validator rules?

查看:24
本文介绍了如何检索 MongoDb 集合验证器规则?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 MongoDB 3.4.4 上,我创建了一个带有验证器的集合,但现在有些插入不符合此规则,我不明白为什么.

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. 有没有办法输出验证器的规则?恐怕应用的规则与我认为的不同...
  2. 有没有办法改善错误信息?在这种情况下,文档验证失败"是非常无用的.

谢谢!

推荐答案

  1. 您可以使用 db.getCollectionInfos()db.getCollectionInfos({name: "myCollection"}) 查看所有集合的验证规则(以及其他集合信息) 用于特定集合:MongoDB 文档

  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

看看 这个答案.

这篇关于如何检索 MongoDb 集合验证器规则?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆