Trait diesel::query_dsl::BelongingToDsl
source · [−]pub trait BelongingToDsl<T> {
type Output;
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);
Associated Types
Required methods
fn belonging_to(other: T) -> Self::Output
fn belonging_to(other: T) -> Self::Output
Get the record(s) belonging to record(s) other