pub struct QueryBuilder { /* private fields */ }Expand description
A builder for constructing database Queryes.
Implementations§
Source§impl QueryBuilder
impl QueryBuilder
Sourcepub fn build(self) -> Query
pub fn build(self) -> Query
Builds and returns a Query object based on the current state of the QueryBuilder.
Sourcepub fn field(self, field: &str) -> QueryBuilder
pub fn field(self, field: &str) -> QueryBuilder
Adds a field to select in the query.
Sourcepub fn fields<I>(self, fields: I) -> QueryBuilderwhere
I: IntoIterator<Item = &'static str>,
pub fn fields<I>(self, fields: I) -> QueryBuilderwhere
I: IntoIterator<Item = &'static str>,
Adds multiple fields to select in the query.
Sourcepub fn all(self) -> QueryBuilder
pub fn all(self) -> QueryBuilder
Sets the query to select all fields.
Sourcepub fn with(self, table_relation: &str) -> QueryBuilder
pub fn with(self, table_relation: &str) -> QueryBuilder
Adds a relation to eagerly load with the main records.
Sourcepub fn inner_join(
self,
table: &str,
left_col: &str,
right_col: &str,
) -> QueryBuilder
pub fn inner_join( self, table: &str, left_col: &str, right_col: &str, ) -> QueryBuilder
Adds an INNER JOIN operation to this query
Sourcepub fn left_join(
self,
table: &str,
left_col: &str,
right_col: &str,
) -> QueryBuilder
pub fn left_join( self, table: &str, left_col: &str, right_col: &str, ) -> QueryBuilder
Adds a LEFT JOIN operation to this query
Sourcepub fn right_join(
self,
table: &str,
left_col: &str,
right_col: &str,
) -> QueryBuilder
pub fn right_join( self, table: &str, left_col: &str, right_col: &str, ) -> QueryBuilder
Adds a RIGHT JOIN operation to this query
Sourcepub fn full_join(
self,
table: &str,
left_col: &str,
right_col: &str,
) -> QueryBuilder
pub fn full_join( self, table: &str, left_col: &str, right_col: &str, ) -> QueryBuilder
Adds a FULL JOIN operation to this query
Sourcepub fn order_by_asc(self, field: &str) -> QueryBuilder
pub fn order_by_asc(self, field: &str) -> QueryBuilder
Adds an ascending order by clause for the specified field.
Sourcepub fn order_by_desc(self, field: &str) -> QueryBuilder
pub fn order_by_desc(self, field: &str) -> QueryBuilder
Adds a descending order by clause for the specified field.
Sourcepub fn limit(self, limit: usize) -> QueryBuilder
pub fn limit(self, limit: usize) -> QueryBuilder
Sets a limit on the number of records to return.
Sourcepub fn offset(self, offset: usize) -> QueryBuilder
pub fn offset(self, offset: usize) -> QueryBuilder
Sets an offset for pagination.
Sourcepub fn filter(self, filter: Option<Filter>) -> QueryBuilder
pub fn filter(self, filter: Option<Filter>) -> QueryBuilder
Sets a filter for the query, replacing any existing filter.
Sourcepub fn and_where(self, filter: Filter) -> QueryBuilder
pub fn and_where(self, filter: Filter) -> QueryBuilder
Adds a filter to the query, combining with existing filters using AND.
Sourcepub fn or_where(self, filter: Filter) -> QueryBuilder
pub fn or_where(self, filter: Filter) -> QueryBuilder
Adds a filter to the query, combining with existing filters using OR.
Trait Implementations§
Source§impl Clone for QueryBuilder
impl Clone for QueryBuilder
Source§fn clone(&self) -> QueryBuilder
fn clone(&self) -> QueryBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more