CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-beanie

Asynchronous Python ODM for MongoDB with modern Pydantic-based document mapping

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

query-operations.mddocs/

Query Operations

Query response configuration and utility enumerations for sorting and document merging strategies.

Capabilities

Update Response Types

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 update

Sort Direction

class SortDirection(Enum):
    """Sorting direction constants."""
    ASCENDING = 1
    DESCENDING = -1

Merge Strategy

class MergeStrategy(Enum):
    """Strategy for merging documents during sync operations."""
    local = "local"    # Prefer local changes
    remote = "remote"  # Prefer database state

Usage Examples

from 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

docs

bulk-operations.md

custom-types.md

documents.md

events-actions.md

fields-types.md

index.md

initialization.md

migrations.md

query-operations.md

time-series.md

tile.json