Expand description
§Repository Pattern for SeaORM
通过派生宏自动为 Repository 结构体生成 CRUD 方法。
§基本用法
ⓘ
use searepo::{Repository, FindFilter, SearchFilter};
#[derive(Repository)]
#[repository(entity = "entities::user", domain = "User")]
pub struct UserRepository {
db: Arc<DatabaseConnection>,
}§功能选择
- 默认:只生成
find+search相关方法 all = true:生成所有方法include = ["find", "insert"]:只生成指定功能exclude = ["delete"]:排除指定功能
Re-exports§
Structs§
- Database
Connection - Handle a database connection depending on the backend enabled by the feature flags. This creates a connection pool internally (for SQLx connections), and so is cheap to clone.
- OnConflict
- Search
Result - 搜索结果封装
- Select
- Defines a structure to perform select operations
Enums§
- Active
Value - The state of a field in an [ActiveModel][ActiveModelTrait].
- DbErr
- An error from unsuccessful database operations
- Pagination
- 分页策略
Traits§
- Active
Model Trait ActiveModelis a type for constructingINSERTandUPDATEstatements for a particular table.- Column
Trait - API for working with a
Column. Mostly a wrapper of the identically named methods insea_query::Expr - Delete
Filter - 删除过滤器 Trait
- Entity
Trait - An abstract base class for defining Entities.
- Find
Filter - 单条查询过滤器 Trait
- Model
Trait - The interface for Model, implemented by data structs
- Paginator
Trait - A Trait for any type that can paginate results
- Query
Filter - Perform a FILTER opertation on a statement
- Query
Order - Performs ORDER BY operations
- Query
Select - Abstract API for performing queries
- Search
Filter - 列表搜索过滤器 Trait
- Transaction
Trait - Spawn database transaction
- Upsertable
- Upsert 冲突处理策略 Trait
Derive Macros§
- Repository
- 派生宏:为 Repository 结构体自动生成 CRUD 方法