Sync and Async ODM (Object Document Mapper) for MongoDB based on python type hints
ISC License
Bot releases are hidden (Show)
chore(bench): update CodSpeed/action to v2 (#461 by @adriencaccia)
fix: tweak dev container environment (#438 by @Kludex and @art049)
Published by art049 10 months ago
I'm excited to announce ODMantic v1.0.0, with Pydantic v2 support! 🎉
This release brings a range of changes that are aligned with the new Pydantic architecture.
Keeping a maintainable and healthy codebase was especially important.
Thus from now on, ODMantic will not support Python 3.7, Pydantic V1, and Motor 2.x anymore.
Overall, integrating with Pydantic v2 brings around 30% performance improvements on
common operations. ⚡️⚡️⚡️
We have a lot of room to improve the performance further now that we only support Pydantic v2.
There is also a 300% 👀 improvement on the bulk saves crafted by @tiangolo that will be merged soon! 🚀
Special thanks to @tiangolo for his help on this release and for saving me a lot of time
figuring out a particularly annoying bug!
Check out the migration guide to
upgrade your codebase and enjoy this new release!
Support for Python 3.7, Pydantic v1 and Motor 2.x has been dropped
Optional[T]
doesn't have a None
implicit default value anymore
Model.copy
doesn't support the exclude
and include
kwargs anymore
odmantic.Field
doesn't accept extra kwargs anymore since it's slated to be removed in Pydantic
The Config
class is no longer supported and the model_config
dict should be used instead
DocumentParsingError
is no longer a subclass of ValidationError
The __bson__
class method is no longer supported to define BSON encoders on custom types. The new method to customize BSON encoding is to use the WithBSONSerializer
annotation.
Decimals (decimal.Decimal
and bson.Decimal128
) are now serialized as strings in JSON documents
Custom JSON encoders(defined with the json_encoders
config option) are no longer effective on odmantic.bson
types. Annotated types with pydantic.PlainSerializer
should be used instead.
AIOEngineDependency
has been removed since it was deprecated in v0.2.0 in favor of a global engine object
Defining the collection with __collection__
has been removed since it was deprecated in v0.3.0 in favor of the collection
config option
We comply with the new Pydantic method naming, prefixing them with model_
Model.dict
has been deprecated in favor of Model.model_dump
Model.doc
has been deprecated in favor of Model.model_dump_doc
Model.parse_doc
has been deprecated in favor of Model.model_validate_doc
Model.update
has been deprecated in favor of Model.model_update
Model.copy
has been deprecated in favor of Model.model_copy
Published by art049 almost 2 years ago
Published by art049 about 2 years ago
Create new generic types to support generic collection types (#240 by @erny & @art049)
Thus, it's now possible to define models like this in python 3.9+ 🚀:
class User(Model):
scopes: list[str]
friendsIds: list[ObjectId]
skills: set[str]
Allow using generators with in_
and not_in
(#270 by @art049)
Published by art049 about 2 years ago
Add new SyncEngine, support async and sync code (#231 by @tiangolo)
Friendly interface for session and transaction management (documentation) (#244 by @art049)
Implement the engine.remove
method to allow instance deletion from a query (#147 & #237 by @joeriddles & @art049)
Published by art049 about 2 years ago
Upgrade types and add support for instance autocompletion with dataclass_transform
(VS Code autocompletion) (#230 by @tiangolo)
Fix using the shared session when updating a document (#227 by @tiangolo)
Allow models to contain string-based datetime fields that indicate UTC (#136 by @kfox)
Fix Reference
usage with non the non default primary key (#184 by @dynalz)
Fix key_name
use on EmbeddedModels (#195 by @jvanegmond)
Published by art049 over 2 years ago
Update and copy methods:
Update example in README (#192 by @jasper-moment)
⬆️ Update motor requirement from >=2.1.0,<2.5.0 to >=2.1.0,<2.6.0 (#160 by @dependabot[bot])
⬆️ Update typer requirement from ^0.3.2 to ^0.4.1 (#214 by @dependabot[bot])
⬆️ Update mypy requirement from ^0.910 to ^0.942 (#215 by @dependabot[bot])
⬆️ Update fastapi requirement from >=0.61.1,<0.67.0 to >=0.61.1,<0.69.0 (#166 by @dependabot[bot])
⬆️ Update fastapi requirement from >=0.61.1,<0.64.0 to >=0.61.1,<0.67.0 (#150 by @dependabot[bot])
⬆️ Update mypy requirement from ^0.812 to ^0.910 (#142 by @dependabot[bot])
⬆️ Update pytest-asyncio requirement from ^0.14.0 to ^0.15.0 (#125 by @dependabot[bot])
⬆️ Update motor requirement from >=2.1.0,<2.4.0 to >=2.1.0,<2.5.0 (#124 by @dependabot[bot])
⬆️ Update importlib-metadata requirement from >=1,<4 to >=1,<5 (#126 by @dependabot[bot])
⬆️ Update pydocstyle requirement from ^5.1.1 to ^6.0.0 (#119 by @dependabot[bot])
⬆️ Update isort requirement from ~=5.7.0 to ~=5.8.0 (#122 by @dependabot[bot])
⬆️ Update flake8 requirement from ~=3.8.4 to ~=3.9.0 (#116 by @dependabot[bot])
Published by art049 over 3 years ago
Published by art049 over 3 years ago
Fix modified mark clearing on save for nested models (#88 by @Olegt0rr)
Don't replace default field description for ObjectId (#82 by @Olegt0rr)
CI Matrix with Standalone instances, ReplicaSets and Sharded clusters (#91 by @art049)
Update mkdocstrings requirement from ^0.14.0 to ^0.15.0 (#110 by @dependabot[bot])
Update mkdocs-material requirement from ^6.0.2 to ^7.0.3 (#111 by @dependabot[bot])
Update mypy requirement from ^0.800 to ^0.812 (#106 by @dependabot[bot])
Published by art049 over 3 years ago
Remove bypass_document_validation
save option to avoid Not Authorized
errors (#85 by @Olegt0rr)
Fix microseconds issue: use truncation instead of round (#100 by @erny)
Add py.typed to ship typing information for mypy (#101 by @art049)
Fix datetime field default example value naiveness (#103 by @art049)
Update pytz requirement from ^2020.1 to ^2021.1 (#98 by @dependabot[bot])
Update mkdocstrings requirement from ^0.13.2 to ^0.14.0 (#92 by @dependabot[bot])
Update mypy requirement from ^0.790 to ^0.800 (#97 by @dependabot[bot])
Update isort requirement from ~=5.6.4 to ~=5.7.0 (#90 by @dependabot[bot])
Update fastapi requirement from >=0.61.1,<0.63.0 to >=0.61.1,<0.64.0 (#84 by @dependabot[bot])
Published by art049 almost 4 years ago
Migrate to the updated prettier precommit hook (#74 by @art049)
Update uvicorn requirement from ^0.12.1 to ^0.13.0 (#67 by @dependabot[bot])
Update mypy requirement from ^0.782 to ^0.790 (#48 by @dependabot[bot])
Update importlib-metadata requirement from ^1.0 to >=1,<4 (#54 by @dependabot[bot])
Update flake8 requirement from ==3.8.3 to ==3.8.4 (#47 by @dependabot[bot])
Update fastapi requirement from ^0.61.1 to >=0.61.1,<0.63.0 (#59 by @dependabot[bot])
Published by art049 almost 4 years ago
__collection__
to customize the collection name. Prefer the collection
Config option (more details)Allow parsing document with unset fields defaults (documentation) (#28 by @art049)
It's now possible to define custom json_encoders
on the Models
Some other Config
options provided by Pydantic are now available (more details)
Published by art049 almost 4 years ago
skip
and limit
with engine.find
(#25 by @art049)Published by art049 almost 4 years ago
AIOEngineDependency
to prefer a global engine object, more details (#21 by @art049)