Trait rocket_db_pools::diesel::prelude::BelongingToDsl
source · 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§
Required Methods§
sourcefn belonging_to(other: T) -> Self::Output
fn belonging_to(other: T) -> Self::Output
Get the record(s) belonging to record(s) other
Object Safety§
This trait is not object safe.