Skip to content
GitHub

Quickstart

Terminal window
uv add lexigram-nosql

Add an optional backend extra for your driver:

Terminal window
uv add "lexigram-nosql[mongodb]" # motor
uv add "lexigram-nosql[dynamodb]" # aioboto3
uv add "lexigram-nosql[firestore]" # google-cloud-firestore

import asyncio
from lexigram import Application
from lexigram.contracts.data.nosql import DocumentStoreProtocol
from lexigram.nosql import NoSQLModule, NoSQLConfig
async def main() -> None:
async with Application.boot(
name="nosql-demo",
modules=[
NoSQLModule.configure(
NoSQLConfig(driver="mongodb")
),
],
) as app:
store = await app.container.resolve(DocumentStoreProtocol)
collection = store.collection("users")
result = await collection.insert_one(
{"name": "Alice", "email": "alice@example.com"}
)
print(f"Inserted: {result.document_id}")
asyncio.run(main())

  1. NoSQLModule.configure() creates a NoSQLProvider with the given config.
  2. The provider registers a DocumentStoreProtocol singleton in the container.
  3. On boot, the provider connects to the document store.
  4. Services receive the store via constructor injection.
  • Guide — mental model, core concepts, common patterns
  • How-Tos — task-oriented recipes
  • Configuration — every config key with env-var names