Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

afastorm

afastorm 是基于 SQLx 的 Rust ORM,支持 SQLite 和 PostgreSQL。它提供模型元数据、类型化 Repository、数据库迁移和事务操作。Repository 持有 ORM 连接上下文,因此每次操作不需要重复 传入连接池。

afastorm 与 AFaster 解耦。项目提供管理端元数据,但不会生成或托管 HTTP 管理页面;应用可以 根据元数据实现自己的管理界面和权限控制。

特性

  • 使用 Cargo feature 选择 SQLite、PostgreSQL 和可选 SQLx 类型。
  • 通过 #[derive(Model)] 生成模型元数据,并显式注册模型。
  • 提供类型化 CRUD、条件查询和 JSON 路径查找。
  • 支持软删除与乐观版本锁。
  • 支持事务中的 Repository 操作。
  • 提供迁移 API、迁移生成器和命令行工具。
  • 提供 Dialect trait,允许通过 SQLx Any 接入其他方言。

SQLite 和 PostgreSQL 的类型映射并不完全相同,请分别查阅SQLite 类型和 PostgreSQL 类型。

最低支持 Rust 版本为 1.94,与 SQLx 0.9 的要求一致。