A trait-driven, async-first ORM layer for MontRS.
Target Audiences: Application Developers, Framework Contributors, Agents.
montrs-orm provides a unified, SQL-centric interface for interacting with different database backends (SQLite, PostgreSQL). It abstracts driver-specific details while maintaining high-performance async access.
- Backend Lock-in: Allows switching between SQLite (local dev) and PostgreSQL (production) with minimal code changes.
- Boilerplate: Automates row-to-struct mapping and connection pool management.
- Type Safety: Ensures that database queries and results are verified at compile-time or through structured traits.
- Query DSL: It does not force a complex, non-SQL DSL (like Diesel). It prefers clean SQL or simple builder patterns.
- Migration Management: It does not handle complex schema migrations (use external tools like
sqlx-cliorsea-orm-clias recommended in our docs). - Auto-Caching: It does not implement implicit query caching.
It provides the persistence layer for Plates. It implements the traits defined in montrs-core for data access.
- When building a feature that requires persistent data storage.
- When implementing a custom database backend or driver.
- When defining data models that need to be persisted in a relational database.
- SQL Preference: Prefer writing raw SQL queries using the provided backend execute methods over complex abstractions.
- Schema Discovery: Read the struct definitions that implement
FromRowto understand the database schema. - Error Mapping: This package implements
AgentErrorforDbError, providing specific codes for constraint violations, connection failures, etc. - Constraints: Assume all database operations are
asyncand must be awaited within anActionorLoader.