Overview
AsyncMongoStorage provides an asynchronous MongoDB-based storage backend. Supports both Motor (legacy) and PyMongo async (recommended) clients. Ideal for document-based applications, flexible schemas, and horizontally scalable deployments.
Basic Usage
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
db_url | str | None | MongoDB connection URL |
db_name | str | "upsonic" | Database name to use |
db_client | AsyncIOMotorClient or AsyncMongoClient | None | Pre-configured async MongoDB client |
session_collection | str | None | Custom name for the session collection |
user_memory_collection | str | None | Custom name for the user memory collection |
id | str | None | Unique identifier for this storage instance |
When both Motor and PyMongo async are available, PyMongo async is preferred. Install using
pip install -U 'pymongo>=4.9' (recommended) or pip install -U motor (legacy).
