pub struct QueryOption {
pub key_word_like_fields: Vec<String>,
pub select: Vec<String>,
pub field_like: Vec<FieldCondition>,
pub field_eq: Vec<FieldCondition>,
pub order_by: Vec<(String, bool)>,
pub joins: Vec<JoinOption>,
pub where_and: Vec<String>,
pub left_join: Vec<JoinOption>,
pub extra_where: Vec<WhereFragment>,
}Expand description
查询选项(对齐 TS 版 QueryOp,保留核心字段)
Fields§
§key_word_like_fields: Vec<String>需要模糊查询的字段
select: Vec<String>查询字段
field_like: Vec<FieldCondition>字段模糊查询
field_eq: Vec<FieldCondition>字段相等查询
order_by: Vec<(String, bool)>排序配置
joins: Vec<JoinOption>关联配置
where_and: Vec<String>额外的 AND 条件(字符串片段),用于快速拼接简单 where
left_join: Vec<JoinOption>左连接配置(与 joins 等价,此处为兼容 TS 命名)
extra_where: Vec<WhereFragment>自定义 where 片段(带参数),用于复杂过滤
Implementations§
Source§impl QueryOption
impl QueryOption
pub fn new() -> Self
pub fn key_word_like_fields<I, S>(self, fields: I) -> Self
pub fn select<I, S>(self, fields: I) -> Self
pub fn add_field_eq( self, column: impl Into<String>, request_param: impl Into<String>, ) -> Self
pub fn add_field_like( self, column: impl Into<String>, request_param: impl Into<String>, ) -> Self
pub fn add_order_by(self, column: impl Into<String>, asc: bool) -> Self
pub fn add_left_join( self, entity: impl Into<String>, alias: impl Into<String>, condition: impl Into<String>, join_type: JoinType, ) -> Self
pub fn add_where_and(self, cond: impl Into<String>) -> Self
pub fn add_where_raw<I, V>(self, sql: impl Into<String>, params: I) -> Self
Sourcepub fn add_where_with<F>(self, f: F) -> Self
pub fn add_where_with<F>(self, f: F) -> Self
通过函数式方式追加 where 片段(便捷包装)
Trait Implementations§
Source§impl Clone for QueryOption
impl Clone for QueryOption
Source§fn clone(&self) -> QueryOption
fn clone(&self) -> QueryOption
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for QueryOption
impl Debug for QueryOption
Source§impl Default for QueryOption
impl Default for QueryOption
Source§fn default() -> QueryOption
fn default() -> QueryOption
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for QueryOption
impl RefUnwindSafe for QueryOption
impl Send for QueryOption
impl Sync for QueryOption
impl Unpin for QueryOption
impl UnsafeUnpin for QueryOption
impl UnwindSafe for QueryOption
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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