Struct pg_worm::query::SelectBuilder
source · pub struct SelectBuilder { /* private fields */ }Expand description
QueryBuilder for SELECT queries.
Implementations§
source§impl SelectBuilder
impl SelectBuilder
sourcepub fn new(cols: Vec<&'static DynCol>) -> SelectBuilder
pub fn new(cols: Vec<&'static DynCol>) -> SelectBuilder
sourcepub fn filter(self, new_filter: Filter) -> SelectBuilder
pub fn filter(self, new_filter: Filter) -> SelectBuilder
sourcepub fn join(
self,
column: &'static DynCol,
on_column: &'static DynCol,
join_type: JoinType
) -> SelectBuilder
pub fn join( self, column: &'static DynCol, on_column: &'static DynCol, join_type: JoinType ) -> SelectBuilder
Add a Join to the select query.
Example
ⓘ
use pg_worm::{Model, Query, QueryBuilder, JoinType};
#[derive(Model)]
struct Book {
#[column(primary_key, auto)]
id: i64,
title: String,
author_id: i64
}
#[derive(Model)]
struct Author {
#[column(primary_key, auto)]
id: i64,
name: String
}
let q = Query::select([&Book::id, &Book::title, &Author::name])
.join(&Book::author_id, &Author::id, JoinType::Inner)
.filter(Author::name.eq("Marx"))
.build();sourcepub fn limit(self, n: usize) -> SelectBuilder
pub fn limit(self, n: usize) -> SelectBuilder
Add a LIMIT to your query.
Trait Implementations§
source§impl QueryBuilder for SelectBuilder
impl QueryBuilder for SelectBuilder
Auto Trait Implementations§
impl !RefUnwindSafe for SelectBuilder
impl !Send for SelectBuilder
impl !Sync for SelectBuilder
impl Unpin for SelectBuilder
impl !UnwindSafe for SelectBuilder
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