pub struct Db { /* private fields */ }Expand description
快捷查询入口(think-orm Db::name() 风格)
不要求定义 Model,仅靠表名 + 方言即可生成 SQL。
Implementations§
Source§impl Db
impl Db
Sourcepub fn where_cond(self, condition: impl Into<String>) -> Db
👎Deprecated since 1.3.0: P0-2: 字符串拼接存在 SQL 注入风险,请使用 where_eq/where_ne/where_gt/where_lt/where_like 等参数化方法
pub fn where_cond(self, condition: impl Into<String>) -> Db
P0-2: 字符串拼接存在 SQL 注入风险,请使用 where_eq/where_ne/where_gt/where_lt/where_like 等参数化方法
WHERE 条件(AND)— 字符串拼接,存在 SQL 注入风险
⚠️ 已废弃:请使用 where_eq / where_gt 等参数化方法替代。
Sourcepub fn or_where(self, condition: impl Into<String>) -> Db
👎Deprecated since 1.3.0: P0-2: 字符串拼接存在 SQL 注入风险,请使用 or_where_eq/or_where_ne/or_where_gt 等参数化方法
pub fn or_where(self, condition: impl Into<String>) -> Db
P0-2: 字符串拼接存在 SQL 注入风险,请使用 or_where_eq/or_where_ne/or_where_gt 等参数化方法
WHERE 条件(OR)— 字符串拼接,存在 SQL 注入风险
⚠️ 已废弃:请使用 or_where_eq / or_where_gt 等参数化方法替代。
Sourcepub fn where_eq(self, field: impl Into<String>, value: Value) -> Db
pub fn where_eq(self, field: impl Into<String>, value: Value) -> Db
P0-2:参数化等值条件 field = ?(AND 关系)
Sourcepub fn where_ne(self, field: impl Into<String>, value: Value) -> Db
pub fn where_ne(self, field: impl Into<String>, value: Value) -> Db
P0-2:参数化不等条件 field != ?(AND 关系)
Sourcepub fn where_gt(self, field: impl Into<String>, value: Value) -> Db
pub fn where_gt(self, field: impl Into<String>, value: Value) -> Db
P0-2:参数化大于条件 field > ?(AND 关系)
Sourcepub fn where_ge(self, field: impl Into<String>, value: Value) -> Db
pub fn where_ge(self, field: impl Into<String>, value: Value) -> Db
P0-2:参数化大于等于条件 field >= ?(AND 关系)
Sourcepub fn where_lt(self, field: impl Into<String>, value: Value) -> Db
pub fn where_lt(self, field: impl Into<String>, value: Value) -> Db
P0-2:参数化小于条件 field < ?(AND 关系)
Sourcepub fn where_le(self, field: impl Into<String>, value: Value) -> Db
pub fn where_le(self, field: impl Into<String>, value: Value) -> Db
P0-2:参数化小于等于条件 field <= ?(AND 关系)
Sourcepub fn where_like(self, field: impl Into<String>, pattern: Value) -> Db
pub fn where_like(self, field: impl Into<String>, pattern: Value) -> Db
P0-2:参数化 LIKE 条件 field LIKE ?(AND 关系)
Sourcepub fn or_where_eq(self, field: impl Into<String>, value: Value) -> Db
pub fn or_where_eq(self, field: impl Into<String>, value: Value) -> Db
P0-2:参数化 OR 等值条件 OR field = ?
Sourcepub fn or_where_ne(self, field: impl Into<String>, value: Value) -> Db
pub fn or_where_ne(self, field: impl Into<String>, value: Value) -> Db
P0-2:参数化 OR 不等条件 OR field != ?
Sourcepub fn or_where_gt(self, field: impl Into<String>, value: Value) -> Db
pub fn or_where_gt(self, field: impl Into<String>, value: Value) -> Db
P0-2:参数化 OR 大于条件 OR field > ?
Sourcepub fn or_where_ge(self, field: impl Into<String>, value: Value) -> Db
pub fn or_where_ge(self, field: impl Into<String>, value: Value) -> Db
P0-2:参数化 OR 大于等于条件 OR field >= ?
Sourcepub fn or_where_lt(self, field: impl Into<String>, value: Value) -> Db
pub fn or_where_lt(self, field: impl Into<String>, value: Value) -> Db
P0-2:参数化 OR 小于条件 OR field < ?
Sourcepub fn or_where_le(self, field: impl Into<String>, value: Value) -> Db
pub fn or_where_le(self, field: impl Into<String>, value: Value) -> Db
P0-2:参数化 OR 小于等于条件 OR field <= ?
Sourcepub fn or_where_like(self, field: impl Into<String>, pattern: Value) -> Db
pub fn or_where_like(self, field: impl Into<String>, pattern: Value) -> Db
P0-2:参数化 OR LIKE 条件 OR field LIKE ?
Sourcepub fn where_between(
self,
field: impl Into<String>,
start: Value,
end: Value,
) -> Db
pub fn where_between( self, field: impl Into<String>, start: Value, end: Value, ) -> Db
WHERE BETWEEN
Sourcepub fn where_null(self, field: impl Into<String>) -> Db
pub fn where_null(self, field: impl Into<String>) -> Db
WHERE IS NULL
Sourcepub fn where_not_null(self, field: impl Into<String>) -> Db
pub fn where_not_null(self, field: impl Into<String>) -> Db
WHERE IS NOT NULL
Sourcepub fn order_desc(self, field: impl Into<String>) -> Db
pub fn order_desc(self, field: impl Into<String>) -> Db
ORDER BY field DESC
Sourcepub fn join_inner(
self,
table: impl Into<String>,
on_left: impl Into<String>,
on_right: impl Into<String>,
) -> Db
pub fn join_inner( self, table: impl Into<String>, on_left: impl Into<String>, on_right: impl Into<String>, ) -> Db
INNER JOIN
Sourcepub fn join_left(
self,
table: impl Into<String>,
on_left: impl Into<String>,
on_right: impl Into<String>,
) -> Db
pub fn join_left( self, table: impl Into<String>, on_left: impl Into<String>, on_right: impl Into<String>, ) -> Db
LEFT JOIN
Sourcepub fn join_right(
self,
table: impl Into<String>,
on_left: impl Into<String>,
on_right: impl Into<String>,
) -> Db
pub fn join_right( self, table: impl Into<String>, on_left: impl Into<String>, on_right: impl Into<String>, ) -> Db
RIGHT JOIN
Sourcepub fn build_select(&self) -> String
pub fn build_select(&self) -> String
构建 SELECT SQL
Sourcepub fn build_delete(&self) -> String
pub fn build_delete(&self) -> String
构建 DELETE SQL
Sourcepub fn build_count(&self) -> String
pub fn build_count(&self) -> String
构建 COUNT SQL
Sourcepub fn build_exists(&self) -> String
pub fn build_exists(&self) -> String
构建 EXISTS SQL
Auto Trait Implementations§
impl !RefUnwindSafe for Db
impl !UnwindSafe for Db
impl Freeze for Db
impl Send for Db
impl Sync for Db
impl Unpin for Db
impl UnsafeUnpin for Db
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more