pub struct JoinOn { /* 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::new()
.fields([TaskColumn::Id, TaskColumn::Name, TaskColumn::ProjectId])
.and_eq(TaskColumn::Status, "Completed")
.and(
QueryBuilder::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::new::<Project>()
.eq(TaskColumn::ProjectId, ProjectColumn::Id);
let entries = Task::lookup::<Project, Map>(&query, &[join_on]).await?;Implementations§
Source§impl JoinOn
impl JoinOn
Sourcepub fn inner_join<M: Schema>() -> Self
pub fn inner_join<M: Schema>() -> Self
Constructs an instance with the INNER JOIN type.
Sourcepub fn right_join<M: Schema>() -> Self
pub fn right_join<M: Schema>() -> Self
Constructs an instance with the RIGHT (OUTER) JOIN type.
Sourcepub fn cross_join<M: Schema>() -> Self
pub fn cross_join<M: Schema>() -> Self
Constructs an instance with the CROSS JOIN type.
Sourcepub fn eq<E1, E2, C1, C2>(self, left_col: C1, right_col: C2) -> Self
pub fn eq<E1, E2, C1, C2>(self, left_col: C1, right_col: C2) -> Self
Specifies a relation for which the left column is equal to the right column.
Sourcepub fn ne<E1, E2, C1, C2>(self, left_col: C1, right_col: C2) -> Self
pub fn ne<E1, E2, C1, C2>(self, left_col: C1, right_col: C2) -> Self
Specifies a relation for which the left column is not equal to the right column.
Sourcepub fn lt<E1, E2, C1, C2>(self, left_col: C1, right_col: C2) -> Self
pub fn lt<E1, E2, C1, C2>(self, left_col: C1, right_col: C2) -> Self
Specifies a relation for which the left column is less than the right column.
Sourcepub fn le<E1, E2, C1, C2>(self, left_col: C1, right_col: C2) -> Self
pub fn le<E1, E2, C1, C2>(self, left_col: C1, right_col: C2) -> Self
Specifies a relation for which the left column is not greater than the right column.
Sourcepub fn gt<E1, E2, C1, C2>(self, left_col: C1, right_col: C2) -> Self
pub fn gt<E1, E2, C1, C2>(self, left_col: C1, right_col: C2) -> Self
Specifies a relation for which the left column is greater than the right column.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for JoinOn
impl RefUnwindSafe for JoinOn
impl Send for JoinOn
impl Sync for JoinOn
impl Unpin for JoinOn
impl UnwindSafe for JoinOn
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