Asynchronous Python ODM for MongoDB with modern Pydantic-based document mapping
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Query response configuration and utility enumerations for sorting and document merging strategies.
class UpdateResponse(Enum):
"""Specify what to return from update operations."""
UPDATE_RESULT = "update_result" # Return update result info
OLD_DOCUMENT = "old_document" # Return document before update
NEW_DOCUMENT = "new_document" # Return document after updateclass SortDirection(Enum):
"""Sorting direction constants."""
ASCENDING = 1
DESCENDING = -1class MergeStrategy(Enum):
"""Strategy for merging documents during sync operations."""
local = "local" # Prefer local changes
remote = "remote" # Prefer database statefrom beanie import Document, UpdateResponse, SortDirection
class Product(Document):
name: str
price: float
class Settings:
collection = "products"
# Using UpdateResponse
old_doc = await Product.find_one({"name": "laptop"}).update(
{"$set": {"price": 999.99}},
response_type=UpdateResponse.OLD_DOCUMENT
)
# Using SortDirection
products = await Product.find().sort([("price", SortDirection.ASCENDING)]).to_list()Install with Tessl CLI
npx tessl i tessl/pypi-beanie