[][src]Trait diesel::query_dsl::BelongingToDsl

pub trait BelongingToDsl<T> {
    type Output;
    fn belonging_to(other: T) -> Self::Output;
}

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);

Associated Types

type Output

The query returned by belonging_to

Loading content...

Required methods

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

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

Loading content...

Implementors

impl<'a, Parent, Child> BelongingToDsl<&'a Vec<Parent>> for Child where
    Child: BelongingToDsl<&'a [Parent]>, 
[src]

type Output = Child::Output

impl<'a, Parent, Child> BelongingToDsl<&'a Parent> for Child where
    &'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
[src]

type Output = FindBy<Child::Table, Child::ForeignKeyColumn, <&'a Parent as Identifiable>::Id>

impl<'a, Parent, Child> BelongingToDsl<&'a [Parent]> for Child where
    &'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
[src]

type Output = Filter<Child::Table, EqAny<Child::ForeignKeyColumn, Vec<<&'a Parent as Identifiable>::Id>>>

Loading content...