We should add more documentation on how to use CodecOptions. For example, it's very simple to configure pymongo to return dictionaries that also support convenient attribute access:
from pymongo import MongoClient class AttributeDict(dict): """A dict that supports attribute access.""" def __getattr__(self, key): return self[key] def __setattr__(self, key, value): self[key] = value client = MongoClient(document_class=AttributeDict) client.test.test.insert_one({'field': {'nested': {'field': 1}}}) doc = client.test.test.find_one({}) assert doc.field.nested.field == 1
- is depended on by
-
PYTHON-1557 Release PyMongo 3.7
- Closed