Skip to main content

MongoDB

Document-based state storage with MongoDB.

Setup

# Docker
docker run -d -p 27017:27017 mongo

# Install driver
pip install pymongo

Usage

from praisonai.persistence.factory import create_state_store

store = create_state_store(
    "mongodb",
    url="mongodb://localhost:27017/praisonai"
)

# Store state
store.set("user:123", {"name": "Alice", "preferences": {}})

# Retrieve state
state = store.get("user:123")

CLI

praisonai persistence doctor --state-url "mongodb://localhost:27017/praisonai"

Configuration

OptionDescription
urlMongoDB connection URL
databaseDatabase name (default: praisonai)
collectionCollection name (default: state)