mirror of
https://git.joinplu.me/Plume/Plume.git
synced 2024-12-23 10:30:41 +00:00
Add relation between blog and authors
This commit is contained in:
parent
68db4a82cf
commit
474f063542
1 changed files with 2 additions and 2 deletions
|
@ -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 a new issue