The Precision ODM for Asynchronous MongoDB & Pydantic.
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vellum_odm-0.1.0.tar.gz.
File metadata
- Download URL: vellum_odm-0.1.0.tar.gz
- Upload date:
- Size: 17.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a09c0a4ba8a2ebd31c3f27a1beed8e331473fe887e879e3460eb5dfa2b4544a
|
|
| MD5 |
e5e66279784da301f2aa09f718565ab8
|
|
| BLAKE2b-256 |
55d958560c48fe39729dde79a67763d8c0ba9a72511968afc8d494bdda3b23bb
|
Provenance
The following attestation bundles were made for vellum_odm-0.1.0.tar.gz:
Publisher:
ci.yml on wailbentafat/Vellum
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vellum_odm-0.1.0.tar.gz -
Subject digest:
9a09c0a4ba8a2ebd31c3f27a1beed8e331473fe887e879e3460eb5dfa2b4544a - Sigstore transparency entry: 1633965331
- Sigstore integration time:
-
Permalink:
wailbentafat/Vellum@4dee008586e75972fd6dc2aabb3eb3fb26d6a8e8 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/wailbentafat
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@4dee008586e75972fd6dc2aabb3eb3fb26d6a8e8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file vellum_odm-0.1.0-py3-none-any.whl.
File metadata
- Download URL: vellum_odm-0.1.0-py3-none-any.whl
- Upload date:
- Size: 24.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e2a8c778fe18eb42e2e859bd6bb8083fbf8370510996ca8f5776cb7c3c33f2d
|
|
| MD5 |
6f755dad4d1743adc4462b5d4c29e581
|
|
| BLAKE2b-256 |
a2010f4d14f32360f2648a73d80e99bb79fcf1c0480d4f8beddb08ac70323764
|
Provenance
The following attestation bundles were made for vellum_odm-0.1.0-py3-none-any.whl:
Publisher:
ci.yml on wailbentafat/Vellum
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vellum_odm-0.1.0-py3-none-any.whl -
Subject digest:
0e2a8c778fe18eb42e2e859bd6bb8083fbf8370510996ca8f5776cb7c3c33f2d - Sigstore transparency entry: 1633965340
- Sigstore integration time:
-
Permalink:
wailbentafat/Vellum@4dee008586e75972fd6dc2aabb3eb3fb26d6a8e8 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/wailbentafat
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@4dee008586e75972fd6dc2aabb3eb3fb26d6a8e8 -
Trigger Event:
push
-
Statement type: