taitan_orm

Trait SqlApi

Source
pub trait SqlApi {
Show 14 methods // Required methods async fn insert(&mut self, entity: &dyn Entity) -> Result<bool>; async fn upsert(&mut self, entity: &dyn Entity) -> Result<bool>; async fn update<M: Mutation>( &mut self, mutation: &M, unique: &dyn Unique<Mutation = M>, ) -> Result<bool>; async fn change<M: Mutation>( &mut self, mutation: &M, location: &M::Location, ) -> Result<u64>; async fn delete<M: Mutation>( &mut self, unique: &dyn Unique<Mutation = M>, ) -> Result<bool>; async fn purify(&mut self, location: &dyn Location) -> Result<u64>; async fn select<DB: Database, SE, M>( &mut self, selection: &SE::Selection, unique: &dyn Unique<Mutation = M>, ) -> Result<Option<SE>> where M: Mutation, SE: SelectedEntity<DB> + Send + Unpin; async fn search<DB: Database, SE>( &mut self, selection: &SE::Selection, location: &dyn Location, order_by: &dyn OrderBy, ) -> Result<Vec<SE>> where SE: SelectedEntity<DB> + Send + Unpin; async fn search_paged<DB: Database, SE>( &mut self, selection: &SE::Selection, location: &dyn Location, order_by: &dyn OrderBy, page: &Pagination, ) -> Result<PagedList<DB, SE>> where SE: SelectedEntity<DB> + Send + Unpin; async fn devour<DB: Database, SE>( &mut self, selection: &SE::Selection, order_by: &dyn OrderBy, ) -> Result<Vec<SE>> where SE: SelectedEntity<DB> + Send + Unpin; async fn devour_paged<DB: Database, SE>( &mut self, selection: &SE::Selection, order_by: &dyn OrderBy, page: &Pagination, ) -> Result<PagedList<DB, SE>> where SE: SelectedEntity<DB> + Send + Unpin; async fn count(&mut self, location: &dyn Location) -> Result<u64>; async fn count_table(&mut self, table_name: &str) -> Result<u64>; async fn execute_by_template( &mut self, template: &dyn TemplateRecord, ) -> Result<usize>;
}
Expand description

查询语义设计: 返回值语义: option: 返回至多1个元素 vec: 返回元素数组,数组可能为空 page: 返回元素分页数组

行级筛选语义: select: 使用唯一键筛选,对应返回值option search: 使用索引筛选,对应返回值vec/paged devour: 不使用条件筛选,对应返回值vec/paged

字段级筛选语义: selection具备返回all_fields的方法

最终查询api设计: select(selection, unique) -> option

search(selection, location, order_by) search_paged(selection, location, page, order_by)

devour(selection, order_by) devour_paged(selection, page, order_by)

Required Methods§

Source

async fn insert(&mut self, entity: &dyn Entity) -> Result<bool>

Source

async fn upsert(&mut self, entity: &dyn Entity) -> Result<bool>

Source

async fn update<M: Mutation>( &mut self, mutation: &M, unique: &dyn Unique<Mutation = M>, ) -> Result<bool>

Source

async fn change<M: Mutation>( &mut self, mutation: &M, location: &M::Location, ) -> Result<u64>

Source

async fn delete<M: Mutation>( &mut self, unique: &dyn Unique<Mutation = M>, ) -> Result<bool>

Source

async fn purify(&mut self, location: &dyn Location) -> Result<u64>

Source

async fn select<DB: Database, SE, M>( &mut self, selection: &SE::Selection, unique: &dyn Unique<Mutation = M>, ) -> Result<Option<SE>>
where M: Mutation, SE: SelectedEntity<DB> + Send + Unpin,

Source

async fn search<DB: Database, SE>( &mut self, selection: &SE::Selection, location: &dyn Location, order_by: &dyn OrderBy, ) -> Result<Vec<SE>>
where SE: SelectedEntity<DB> + Send + Unpin,

Source

async fn search_paged<DB: Database, SE>( &mut self, selection: &SE::Selection, location: &dyn Location, order_by: &dyn OrderBy, page: &Pagination, ) -> Result<PagedList<DB, SE>>
where SE: SelectedEntity<DB> + Send + Unpin,

Source

async fn devour<DB: Database, SE>( &mut self, selection: &SE::Selection, order_by: &dyn OrderBy, ) -> Result<Vec<SE>>
where SE: SelectedEntity<DB> + Send + Unpin,

根据表中所有数据

Source

async fn devour_paged<DB: Database, SE>( &mut self, selection: &SE::Selection, order_by: &dyn OrderBy, page: &Pagination, ) -> Result<PagedList<DB, SE>>
where SE: SelectedEntity<DB> + Send + Unpin,

Source

async fn count(&mut self, location: &dyn Location) -> Result<u64>

Source

async fn count_table(&mut self, table_name: &str) -> Result<u64>

Source

async fn execute_by_template( &mut self, template: &dyn TemplateRecord, ) -> Result<usize>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§