Reputation: 422
In mongo shell I can retrieve the validator info of one collection with
db.getCollectionInfos({name: 'collection'})[0].options.validator
How is it done with pymongo?
Upvotes: 0
Views: 162
Reputation: 8834
It's a bit obscure but it can be done:
import pymongo
db = pymongo.MongoClient()['mydatabase']
x = db.command({'listCollections': 1, 'filter': {'name': 'testcollection'}})
print(x.get('cursor').get('firstBatch')[0].get('options').get('validator'))
Upvotes: 1