pub struct QueryBuilder<E>where
E: Entity,{ /* private fields */ }Expand description
Query Builder for constructing type-safe SQL queries
§Type Parameters
E- The Entity type this query is built for
§Example
use ormkit::query::{QueryBuilder, FilterOp, Order};
let query = QueryBuilder::<User>::new()
.filter("email", FilterOp::Eq, "user@example.com")
.order("created_at", Order::Desc)
.limit(10)
.build();Implementations§
Source§impl<E> QueryBuilder<E>where
E: Entity,
impl<E> QueryBuilder<E>where
E: Entity,
Sourcepub fn select_all(
self,
columns: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn select_all( self, columns: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Sourcepub fn select_raw(self, expr: impl Into<String>) -> Self
pub fn select_raw(self, expr: impl Into<String>) -> Self
Sourcepub fn filter(
self,
column: impl Into<String>,
op: FilterOp,
value: impl Into<String>,
) -> Self
pub fn filter( self, column: impl Into<String>, op: FilterOp, value: impl Into<String>, ) -> Self
Sourcepub fn filter_in(
self,
column: impl Into<String>,
op: FilterOp,
values: Vec<impl Into<String>>,
) -> Self
pub fn filter_in( self, column: impl Into<String>, op: FilterOp, values: Vec<impl Into<String>>, ) -> Self
Add a WHERE filter with multiple values (for IN/NOT IN)
§Arguments
column- The column name to filter onop- The filter operator (should be In or NotIn)values- The filter values
Sourcepub fn filter_between(
self,
column: impl Into<String>,
low: impl Into<String>,
high: impl Into<String>,
) -> Self
pub fn filter_between( self, column: impl Into<String>, low: impl Into<String>, high: impl Into<String>, ) -> Self
Add a WHERE filter with a range (for BETWEEN)
§Arguments
column- The column name to filter onlow- The low valuehigh- The high value
Sourcepub fn filter_raw(self, expr: impl Into<String>) -> Self
pub fn filter_raw(self, expr: impl Into<String>) -> Self
Sourcepub fn join(
self,
join_type: JoinType,
table: impl Into<String>,
on_column: impl Into<String>,
on_foreign_column: impl Into<String>,
) -> Self
pub fn join( self, join_type: JoinType, table: impl Into<String>, on_column: impl Into<String>, on_foreign_column: impl Into<String>, ) -> Self
Add a JOIN clause
§Arguments
join_type- The type of jointable- The table to joinon_column- The column in the current tableon_foreign_column- The column in the joined table
Sourcepub fn inner_join(
self,
table: impl Into<String>,
on_column: impl Into<String>,
on_foreign_column: impl Into<String>,
) -> Self
pub fn inner_join( self, table: impl Into<String>, on_column: impl Into<String>, on_foreign_column: impl Into<String>, ) -> Self
Add an INNER JOIN
§Arguments
table- The table to joinon_column- The column in the current tableon_foreign_column- The column in the joined table
Sourcepub fn left_join(
self,
table: impl Into<String>,
on_column: impl Into<String>,
on_foreign_column: impl Into<String>,
) -> Self
pub fn left_join( self, table: impl Into<String>, on_column: impl Into<String>, on_foreign_column: impl Into<String>, ) -> Self
Add a LEFT JOIN
§Arguments
table- The table to joinon_column- The column in the current tableon_foreign_column- The column in the joined table
Sourcepub fn order_with_table(
self,
table: impl Into<String>,
column: impl Into<String>,
order: Order,
) -> Self
pub fn order_with_table( self, table: impl Into<String>, column: impl Into<String>, order: Order, ) -> Self
Add an ORDER BY clause with explicit table
§Arguments
table- The table namecolumn- The column nameorder- The sort direction
Trait Implementations§
Source§impl<E> Clone for QueryBuilder<E>
impl<E> Clone for QueryBuilder<E>
Source§fn clone(&self) -> QueryBuilder<E>
fn clone(&self) -> QueryBuilder<E>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<E> Debug for QueryBuilder<E>
impl<E> Debug for QueryBuilder<E>
Auto Trait Implementations§
impl<E> Freeze for QueryBuilder<E>
impl<E> RefUnwindSafe for QueryBuilder<E>where
E: RefUnwindSafe,
impl<E> Send for QueryBuilder<E>
impl<E> Sync for QueryBuilder<E>
impl<E> Unpin for QueryBuilder<E>where
E: Unpin,
impl<E> UnwindSafe for QueryBuilder<E>where
E: UnwindSafe,
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