pub trait Mode: DbMode {
Show 61 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 timestamps(&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 field_raw(&mut self, expr: &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_raw(&mut self, expr: &str) -> &mut Self;
fn where_in_sub(&mut self, field: &str, sub_sql: &str) -> &mut Self;
fn where_not_in_sub(&mut self, field: &str, sub_sql: &str) -> &mut Self;
fn where_exists(&mut self, sub_sql: &str) -> &mut Self;
fn where_not_exists(&mut self, sub_sql: &str) -> &mut Self;
fn where_column(
&mut self,
field_a: &str,
compare: &str,
field_b: &str,
) -> &mut Self;
fn update_column(&mut self, field_a: &str, compare: &str) -> &mut Self;
fn page(&mut self, page: i32, limit: i32) -> &mut Self;
fn limit(&mut self, count: 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 having(&mut self, expr: &str) -> &mut Self;
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 upsert(
&mut self,
data: JsonValue,
conflict_fields: Vec<&str>,
) -> 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_fields(&mut self, fields: Vec<&str>) -> &mut Self;
fn join(
&mut self,
main_table: &str,
main_fields: &str,
right_table: &str,
right_fields: &str,
) -> &mut Self;
fn join_inner(
&mut self,
table: &str,
main_fields: &str,
second_fields: &str,
) -> &mut Self;
fn join_right(
&mut self,
main_table: &str,
main_fields: &str,
right_table: &str,
right_fields: &str,
) -> &mut Self;
fn join_full(
&mut self,
main_table: &str,
main_fields: &str,
right_table: &str,
right_fields: &str,
) -> &mut Self;
fn union(&mut self, sub_sql: &str) -> &mut Self;
fn union_all(&mut self, sub_sql: &str) -> &mut Self;
fn lock_for_update(&mut self) -> &mut Self;
fn lock_for_share(&mut self) -> &mut Self;
}Required Methods§
fn table_create(&mut self, options: TableOptions) -> JsonValue
fn table_update(&mut self, options: TableOptions) -> JsonValue
Sourcefn table_info(&mut self, table: &str) -> JsonValue
fn table_info(&mut self, table: &str) -> JsonValue
获取表信息
Sourcefn table_is_exist(&mut self, name: &str) -> bool
fn table_is_exist(&mut self, name: &str) -> bool
判断表是否存在
Sourcefn change_table(&mut self, name: &str) -> &mut Self
fn change_table(&mut self, name: &str) -> &mut Self
别名
Sourcefn timestamps(&mut self) -> &mut Self
fn timestamps(&mut self) -> &mut Self
自动时间戳
Sourcefn field_raw(&mut self, expr: &str) -> &mut Self
fn field_raw(&mut self, expr: &str) -> &mut Self
原始表达式字段(不加表前缀,如 “SUM(amount) as total”、“CASE WHEN … END as status_count”)
隐藏字段
fn where_or( &mut self, field: &str, compare: &str, value: JsonValue, ) -> &mut Self
Sourcefn where_raw(&mut self, expr: &str) -> &mut Self
fn where_raw(&mut self, expr: &str) -> &mut Self
原始 WHERE 条件(不加表前缀,如 “YEAR(created_at) = 2026”)
Sourcefn where_in_sub(&mut self, field: &str, sub_sql: &str) -> &mut Self
fn where_in_sub(&mut self, field: &str, sub_sql: &str) -> &mut Self
子查询 WHERE field IN (sub_sql)
Sourcefn where_not_in_sub(&mut self, field: &str, sub_sql: &str) -> &mut Self
fn where_not_in_sub(&mut self, field: &str, sub_sql: &str) -> &mut Self
子查询 WHERE field NOT IN (sub_sql)
fn where_exists(&mut self, sub_sql: &str) -> &mut Self
fn where_not_exists(&mut self, sub_sql: &str) -> &mut Self
Sourcefn where_column(
&mut self,
field_a: &str,
compare: &str,
field_b: &str,
) -> &mut Self
fn where_column( &mut self, field_a: &str, compare: &str, field_b: &str, ) -> &mut Self
比较两个列
Sourcefn update_column(&mut self, field_a: &str, compare: &str) -> &mut Self
fn update_column(&mut self, field_a: &str, compare: &str) -> &mut Self
更新指定列
Sourcefn insert_all(&mut self, data: JsonValue) -> JsonValue
fn insert_all(&mut self, data: JsonValue) -> JsonValue
批量添加
Sourcefn update_all(&mut self, data: JsonValue) -> JsonValue
fn update_all(&mut self, data: JsonValue) -> JsonValue
批量更新
Sourcefn transaction(&mut self) -> bool
fn transaction(&mut self) -> bool
事务开始
fn sql_execute(&mut self, sql: &str) -> Result<JsonValue, String>
fn join_fields(&mut self, fields: Vec<&str>) -> &mut Self
Sourcefn join(
&mut self,
main_table: &str,
main_fields: &str,
right_table: &str,
right_fields: &str,
) -> &mut Self
fn join( &mut self, main_table: &str, main_fields: &str, right_table: &str, right_fields: &str, ) -> &mut Self
连结
- main_table 主表表名
- main_fields 主表字段
- right_table 关联表名
- right_fields 关联字段名
Sourcefn join_inner(
&mut self,
table: &str,
main_fields: &str,
second_fields: &str,
) -> &mut Self
fn join_inner( &mut self, table: &str, main_fields: &str, second_fields: &str, ) -> &mut Self
内连接–用来取交集
- table 链表表名
- main_fields 主表字段
- second_fields 附表关联字段
Sourcefn join_right(
&mut self,
main_table: &str,
main_fields: &str,
right_table: &str,
right_fields: &str,
) -> &mut Self
fn join_right( &mut self, main_table: &str, main_fields: &str, right_table: &str, right_fields: &str, ) -> &mut Self
右连接
Sourcefn join_full(
&mut self,
main_table: &str,
main_fields: &str,
right_table: &str,
right_fields: &str,
) -> &mut Self
fn join_full( &mut self, main_table: &str, main_fields: &str, right_table: &str, right_fields: &str, ) -> &mut Self
全连接
fn union(&mut self, sub_sql: &str) -> &mut Self
fn union_all(&mut self, sub_sql: &str) -> &mut Self
fn lock_for_update(&mut self) -> &mut Self
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.