Mode

Trait Mode 

Source
pub trait Mode: DbMode {
Show 43 methods // Required methods fn table_create(&mut self, options: TableOptions) -> JsonValue; fn table_update(&mut self, options: TableOptions) -> JsonValue; fn table_info(&mut self, table: &str) -> JsonValue; fn table_is_exist(&mut self, name: &str) -> bool; fn table(&mut self, name: &str) -> &mut Self; fn change_table(&mut self, name: &str) -> &mut Self; fn autoinc(&mut self) -> &mut Self; fn fetch_sql(&mut self) -> &mut Self; fn order(&mut self, field: &str, by: bool) -> &mut Self; fn group(&mut self, field: &str) -> &mut Self; fn distinct(&mut self) -> &mut Self; fn json(&mut self, field: &str) -> &mut Self; fn location(&mut self, field: &str) -> &mut Self; fn field(&mut self, field: &str) -> &mut Self; fn hidden(&mut self, name: &str) -> &mut Self; fn where_and( &mut self, field: &str, compare: &str, value: JsonValue, ) -> &mut Self; fn where_or( &mut self, field: &str, compare: &str, value: JsonValue, ) -> &mut Self; fn where_column( &mut self, field_a: &str, compare: &str, field_b: &str, ) -> &mut Self; fn page(&mut self, page: i32, limit: i32) -> &mut Self; fn column(&mut self, field: &str) -> JsonValue; fn count(&mut self) -> JsonValue; fn max(&mut self, field: &str) -> JsonValue; fn min(&mut self, field: &str) -> JsonValue; fn sum(&mut self, field: &str) -> JsonValue; fn avg(&mut self, field: &str) -> JsonValue; fn select(&mut self) -> JsonValue; fn find(&mut self) -> JsonValue; fn value(&mut self, field: &str) -> JsonValue; fn insert(&mut self, data: JsonValue) -> JsonValue; fn insert_all(&mut self, data: JsonValue) -> JsonValue; fn update(&mut self, data: JsonValue) -> JsonValue; fn update_all(&mut self, data: JsonValue) -> JsonValue; fn delete(&mut self) -> JsonValue; fn transaction(&mut self) -> bool; fn commit(&mut self) -> bool; fn rollback(&mut self) -> bool; fn sql(&mut self, sql: &str) -> Result<JsonValue, String>; fn sql_execute(&mut self, sql: &str) -> Result<JsonValue, String>; fn inc(&mut self, field: &str, num: f64) -> &mut Self; fn dec(&mut self, field: &str, num: f64) -> &mut Self; fn buildsql(&mut self) -> String; fn join( &mut self, table: &str, main_fields: &str, right_fields: &str, ) -> &mut Self; fn join_inner( &mut self, table: &str, main_fields: &str, second_fields: &str, ) -> &mut Self;
}

Required Methods§

Source

fn table_create(&mut self, options: TableOptions) -> JsonValue

Source

fn table_update(&mut self, options: TableOptions) -> JsonValue

Source

fn table_info(&mut self, table: &str) -> JsonValue

获取表信息

Source

fn table_is_exist(&mut self, name: &str) -> bool

判断表是否存在

Source

fn table(&mut self, name: &str) -> &mut Self

当前表

Source

fn change_table(&mut self, name: &str) -> &mut Self

别名

Source

fn autoinc(&mut self) -> &mut Self

主键自增

Source

fn fetch_sql(&mut self) -> &mut Self

返回sql语句

Source

fn order(&mut self, field: &str, by: bool) -> &mut Self

排序

Source

fn group(&mut self, field: &str) -> &mut Self

分组

Source

fn distinct(&mut self) -> &mut Self

消除重复记录

Source

fn json(&mut self, field: &str) -> &mut Self

JSON 字段

Source

fn location(&mut self, field: &str) -> &mut Self

location 字段

Source

fn field(&mut self, field: &str) -> &mut Self

显示字段

Source

fn hidden(&mut self, name: &str) -> &mut Self

隐藏字段

Source

fn where_and( &mut self, field: &str, compare: &str, value: JsonValue, ) -> &mut Self

查询

Source

fn where_or( &mut self, field: &str, compare: &str, value: JsonValue, ) -> &mut Self

Source

fn where_column( &mut self, field_a: &str, compare: &str, field_b: &str, ) -> &mut Self

比较两个列

Source

fn page(&mut self, page: i32, limit: i32) -> &mut Self

分页

Source

fn column(&mut self, field: &str) -> JsonValue

查询指定列并返回数组

Source

fn count(&mut self) -> JsonValue

总数量

Source

fn max(&mut self, field: &str) -> JsonValue

最大值

Source

fn min(&mut self, field: &str) -> JsonValue

最小值

Source

fn sum(&mut self, field: &str) -> JsonValue

合计

Source

fn avg(&mut self, field: &str) -> JsonValue

平均值

Source

fn select(&mut self) -> JsonValue

获取集合

Source

fn find(&mut self) -> JsonValue

获取单记录

Source

fn value(&mut self, field: &str) -> JsonValue

获取单一列值

Source

fn insert(&mut self, data: JsonValue) -> JsonValue

添加

Source

fn insert_all(&mut self, data: JsonValue) -> JsonValue

批量添加

Source

fn update(&mut self, data: JsonValue) -> JsonValue

更新

Source

fn update_all(&mut self, data: JsonValue) -> JsonValue

批量更新

Source

fn delete(&mut self) -> JsonValue

删除

Source

fn transaction(&mut self) -> bool

事务开始

Source

fn commit(&mut self) -> bool

事务提交

Source

fn rollback(&mut self) -> bool

事务回滚

Source

fn sql(&mut self, sql: &str) -> Result<JsonValue, String>

sql语句执行

Source

fn sql_execute(&mut self, sql: &str) -> Result<JsonValue, String>

Source

fn inc(&mut self, field: &str, num: f64) -> &mut Self

自增

Source

fn dec(&mut self, field: &str, num: f64) -> &mut Self

自减

Source

fn buildsql(&mut self) -> String

构造子查询

Source

fn join( &mut self, table: &str, main_fields: &str, right_fields: &str, ) -> &mut Self

连结

  • table 链表表名
  • main_fields 主表id字段
  • right_fields 关联字段名
Source

fn join_inner( &mut self, table: &str, main_fields: &str, second_fields: &str, ) -> &mut Self

内连接–用来取交集

  • table 链表表名
  • main_fields 主表字段
  • second_fields 附表关联字段

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§