Add relation between blog and authors
This commit is contained in:
parent
68db4a82cf
commit
474f063542
@ -23,14 +23,14 @@ impl BlogAuthor {
|
|||||||
diesel::insert_into(blog_authors::table)
|
diesel::insert_into(blog_authors::table)
|
||||||
.values(new)
|
.values(new)
|
||||||
.get_result(conn)
|
.get_result(conn)
|
||||||
.expect("Error saving new blog")
|
.expect("Error saving new blog author")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get(conn: &PgConnection, id: i32) -> Option<BlogAuthor> {
|
pub fn get(conn: &PgConnection, id: i32) -> Option<BlogAuthor> {
|
||||||
blog_authors::table.filter(blog_authors::id.eq(id))
|
blog_authors::table.filter(blog_authors::id.eq(id))
|
||||||
.limit(1)
|
.limit(1)
|
||||||
.load::<BlogAuthor>(conn)
|
.load::<BlogAuthor>(conn)
|
||||||
.expect("Error loading blog by id")
|
.expect("Error loading blog author by id")
|
||||||
.into_iter().nth(0)
|
.into_iter().nth(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user