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
Pydantic-compatible custom field types for MongoDB-specific data types like Decimal128 and Binary.
DecimalAnnotation: TypeAlias
"""Pydantic annotation for handling BSON Decimal128 types."""BsonBinary: TypeAlias
"""Pydantic-compatible BSON binary field type."""from beanie import Document, DecimalAnnotation, BsonBinary
from decimal import Decimal
class Product(Document):
name: str
price: DecimalAnnotation # High-precision decimal
image_data: BsonBinary # Binary data
class Settings:
collection = "products"
# Create with custom types
product = Product(
name="Laptop",
price=Decimal("1299.99"),
image_data=b"binary_image_data"
)
await product.insert()Install with Tessl CLI
npx tessl i tessl/pypi-beanie