Vellum
The Precision ODM for Asynchronous MongoDB & Pydantic.
Vellum is a type-safe, async Python ODM for MongoDB built on Pydantic v2 and Motor. It provides a clean repository pattern, fluent aggregation builder, lifecycle hooks, optimistic concurrency, soft deletes, and transactions — all with full type hints.
Installation
pip install vellum-odm
Quick Start
from motor.motor_asyncio import AsyncIOMotorClient
from vellum import VellumBaseModel, VellumRepository, AggregationPipeline
# 1. Define a model
class User(VellumBaseModel):
name: str
email: str
class Settings:
collection_name = "users"
indexes = [{"key": [("email", 1)], "unique": True}]
# 2. Connect and create a repository
client = AsyncIOMotorClient("mongodb://localhost:27017")
db = client["myapp"]
repo = VellumRepository(User, db)
# 3. CRUD
user = await repo.create(User(name="Alice", email="alice@example.com"))
fetched = await repo.get(user.id)
user.name = "Bob"
await repo.update(user.id, user)
await repo.delete(user.id)
# 4. Query
users = await repo.find({"name": "Alice"})
count = await repo.count({"name": "Alice"})
# 5. Aggregation
results = await (
AggregationPipeline(repo.collection)
.match({"status": "active"})
.group("$department", total={"$sum": 1})
.sort([("total", -1)])
.execute()
)
Features
| Feature | Description |
|---|---|
| Type-safe queries | Expression classes for all MongoDB operators (Eq, Gt, In, Regex, ElemMatch, ...) |
| Fluent aggregation | AggregationPipeline with match, group, project, sort, unwind, lookup, etc. |
| Lifecycle hooks | before_insert, after_insert, before_update, ... on your model |
| OCC | OptimisticConcurrencyMixin — automatic version-based conflict detection |
| Soft delete | SoftDeleteMixin — automatic filtering, soft_delete() / restore() |
| Transactions | async with repo.transaction() as session: |
| FastAPI integration | repository_factory for Depends injection |
| Aggregation output models | Pass a Pydantic model to project() / group() for validated results |
Documentation
- Learning Guide — explains bugs found and concepts introduced
- Roadmap — planned features and improvements
Requirements
- Python >= 3.12
- MongoDB >= 4.0 (transactions require a replica set)
License
MIT
Metadata
Release files for vellum-odm 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| vellum_odm-0.1.0.tar.gz | 17.4 kB | With provenance | Details for vellum_odm-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| vellum_odm-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for vellum_odm-0.1.0-py3-none-any.whl |
Total release size: 41.9 kB
Release files / vellum_odm-0.1.0.tar.gz
| Download URL | vellum_odm-0.1.0.tar.gz |
|---|---|
| Size | 17.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9a09c0a4ba8a2ebd31c3f27a1beed8e331473fe887e879e3460eb5dfa2b4544a
|
|
BLAKE2b-256 checksum How to use checksums |
55d958560c48fe39729dde79a67763d8c0ba9a72511968afc8d494bdda3b23bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 26, 2026.
Transparency logRelease files / vellum_odm-0.1.0-py3-none-any.whl
| Download URL | vellum_odm-0.1.0-py3-none-any.whl |
|---|---|
| Size | 24.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0e2a8c778fe18eb42e2e859bd6bb8083fbf8370510996ca8f5776cb7c3c33f2d
|
|
BLAKE2b-256 checksum How to use checksums |
a2010f4d14f32360f2648a73d80e99bb79fcf1c0480d4f8beddb08ac70323764
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 26, 2026.
Transparency logSecurity for vellum-odm 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for vellum_odm-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 26, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.