pub trait BelongingToDsl<T> {
    type Output;

    // Required method
    fn belonging_to(other: T) -> Self::Output;
}
Expand description

Constructs a query that finds record(s) based on directional association with other record(s).

Example

let sean = users.filter(name.eq("Sean")).first::<User>(connection)?;
let tess = users.filter(name.eq("Tess")).first::<User>(connection)?;

let seans_posts = Post::belonging_to(&sean)
    .select(title)
    .load::<String>(connection)?;
assert_eq!(vec!["My first post", "About Rust"], seans_posts);

// A vec or slice can be passed as well
let more_posts = Post::belonging_to(&vec![sean, tess])
    .select(title)
    .load::<String>(connection)?;
assert_eq!(vec!["My first post", "About Rust", "My first post too"], more_posts);

Required Associated Types§

source

type Output

The query returned by belonging_to

Required Methods§

source

fn belonging_to(other: T) -> Self::Output

Get the record(s) belonging to record(s) other

Implementors§

source§

impl<'a, Parent, Child> BelongingToDsl<&'a [Parent]> for Childwhere &'a Parent: Identifiable, Child: HasTable + BelongsTo<Parent>, Vec<<&'a Parent as Identifiable>::Id>: AsInExpression<<Child::ForeignKeyColumn as Expression>::SqlType>, <Child as HasTable>::Table: FilterDsl<EqAny<Child::ForeignKeyColumn, Vec<<&'a Parent as Identifiable>::Id>>>, Child::ForeignKeyColumn: ExpressionMethods, <Child::ForeignKeyColumn as Expression>::SqlType: SqlType,

§

type Output = <<Child as HasTable>::Table as FilterDsl<Grouped<In<<Child as BelongsTo<Parent>>::ForeignKeyColumn, <Vec<<&'a Parent as Identifiable>::Id, Global> as AsInExpression<<<Child as BelongsTo<Parent>>::ForeignKeyColumn as Expression>::SqlType>>::InExpression>>>>::Output

source§

impl<'a, Parent, Child> BelongingToDsl<&'a Vec<Parent, Global>> for Childwhere Child: BelongingToDsl<&'a [Parent]>,

§

type Output = <Child as BelongingToDsl<&'a [Parent]>>::Output

source§

impl<'a, Parent, Child> BelongingToDsl<(&'a [Parent], &'a [Parent])> for Childwhere &'a Parent: Identifiable, Child: HasTable + BelongsTo<Parent>, Vec<<&'a Parent as Identifiable>::Id>: AsInExpression<<Child::ForeignKeyColumn as Expression>::SqlType>, <Child as HasTable>::Table: FilterDsl<EqAny<Child::ForeignKeyColumn, Vec<<&'a Parent as Identifiable>::Id>>>, Child::ForeignKeyColumn: ExpressionMethods, <Child::ForeignKeyColumn as Expression>::SqlType: SqlType,

§

type Output = <<Child as HasTable>::Table as FilterDsl<Grouped<In<<Child as BelongsTo<Parent>>::ForeignKeyColumn, <Vec<<&'a Parent as Identifiable>::Id, Global> as AsInExpression<<<Child as BelongsTo<Parent>>::ForeignKeyColumn as Expression>::SqlType>>::InExpression>>>>::Output

source§

impl<'a, Parent, Child> BelongingToDsl<&'a Parent> for Childwhere &'a Parent: Identifiable, Child: HasTable + BelongsTo<Parent>, <&'a Parent as Identifiable>::Id: AsExpression<<Child::ForeignKeyColumn as Expression>::SqlType>, Child::Table: FilterDsl<Eq<Child::ForeignKeyColumn, <&'a Parent as Identifiable>::Id>>, Child::ForeignKeyColumn: ExpressionMethods, <Child::ForeignKeyColumn as Expression>::SqlType: SqlType,

§

type Output = <<Child as HasTable>::Table as FilterDsl<Grouped<Eq<<Child as BelongsTo<Parent>>::ForeignKeyColumn, <<&'a Parent as Identifiable>::Id as AsExpression<<<Child as BelongsTo<Parent>>::ForeignKeyColumn as Expression>::SqlType>>::Expression>>>>::Output