Gault¶
A lightweight Object Document Mapper (ODM) for MongoDB with Python type hints and state tracking.
Why Gault?¶
- Type-safe — MongoDB documents with Python type hints and field aliasing
- State tracking — Automatic dirty field detection for atomic updates
- Pipelines — Fluent, immutable aggregation pipeline builder
- Async & Sync — Both
AsyncManagerandManagerfor any codebase
Quick example¶
from gault import Schema, Field, configure, AsyncManager
class Person(Schema, collection="people"):
id: Field[int] = configure(pk=True)
name: Field[str]
age: Field[int] = configure(db_alias="person_age")
manager = AsyncManager(database)
# Insert
person = Person(id=1, name="Alice", age=30)
await manager.insert(person)
# Query
person = await manager.get(Person, filter=Person.id == 1)
# Atomic update (only changed fields)
person.age = 31
await manager.save(person, atomic=True)
Learn¶
-
Tutorials — Learn Gault step by step
Start here if you're new. Build your first schema, insert documents, and query data.
-
How-to Guides — Solve specific problems
Filter documents, paginate results, track dirty fields, and compose pipelines.
-
Reference — Complete API documentation
Every class, method, and parameter documented with examples.
-
Explanation — Understand the design
Why Schema vs Model? How does state tracking work? Pipeline architecture explained.
Installation¶
Requirements¶
- Python >= 3.11
- PyMongo >= 4.15.4