pub struct JoinOn<L: Schema, R: Schema> { /* private fields */ }
Expand description
SQL joins on two tables.
§Examples
ⓘ
use crate::model::{Project, ProjectColumn, Task, TaskColumn};
use zino_core::Map;
use zino_orm::{JoinOn, QueryBuilder, Schema};
let query = QueryBuilder::<Task>::new()
.fields([TaskColumn::Id, TaskColumn::Name, TaskColumn::ProjectId])
.and_eq(TaskColumn::Status, "Completed")
.and(
QueryBuilder::<Project>::new()
.alias(ProjectColumn::Name, "project_name")
.fields([ProjectColumn::StartDate, ProjectColumn::EndDate])
.and_overlaps(
(ProjectColumn::StartDate, ProjectColumn::EndDate),
("2023-10-01", "2023-10-07"),
),
)
.order_desc(TaskColumn::UpdatedAt)
.build();
let join_on = JoinOn::<Task, Project>::new()
.eq(TaskColumn::ProjectId, ProjectColumn::Id);
let entries = Task::lookup::<Project, Map>(&query, &join_on).await?;
Implementations§
Source§impl<L: Schema, R: Schema> JoinOn<L, R>
impl<L: Schema, R: Schema> JoinOn<L, R>
Sourcepub fn inner_join() -> Self
pub fn inner_join() -> Self
Constructs an instance for the INNER JOIN
.
Sourcepub fn right_join() -> Self
pub fn right_join() -> Self
Constructs an instance for the RIGHT (OUTER) JOIN
.
Sourcepub fn cross_join() -> Self
pub fn cross_join() -> Self
Constructs an instance for the CROSS JOIN
.
Source§impl<L: Entity + Schema, R: Entity + Schema> JoinOn<L, R>
impl<L: Entity + Schema, R: Entity + Schema> JoinOn<L, R>
Sourcepub fn eq(self, left_col: L::Column, right_col: R::Column) -> Self
pub fn eq(self, left_col: L::Column, right_col: R::Column) -> Self
Specifies a relation for which the left column is equal to the right column.
Sourcepub fn ne(self, left_col: L::Column, right_col: R::Column) -> Self
pub fn ne(self, left_col: L::Column, right_col: R::Column) -> Self
Specifies a relation for which the left column is not equal to the right column.
Sourcepub fn lt(self, left_col: L::Column, right_col: R::Column) -> Self
pub fn lt(self, left_col: L::Column, right_col: R::Column) -> Self
Specifies a relation for which the left column is less than the right column.
Sourcepub fn le(self, left_col: L::Column, right_col: R::Column) -> Self
pub fn le(self, left_col: L::Column, right_col: R::Column) -> Self
Specifies a relation for which the left column is not greater than the right column.
Trait Implementations§
Auto Trait Implementations§
impl<L, R> Freeze for JoinOn<L, R>
impl<L, R> RefUnwindSafe for JoinOn<L, R>where
L: RefUnwindSafe,
R: RefUnwindSafe,
impl<L, R> Send for JoinOn<L, R>
impl<L, R> Sync for JoinOn<L, R>
impl<L, R> Unpin for JoinOn<L, R>
impl<L, R> UnwindSafe for JoinOn<L, R>where
L: UnwindSafe,
R: 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