80a4dae8bd
- Use `Result` as much as possible - Display errors instead of panicking TODO (maybe in another PR? this one is already quite big): - Find a way to merge Ructe/ErrorPage types, so that we can have routes returning `Result<X, ErrorPage>` instead of panicking when we have an `Error` - Display more details about the error, to make it easier to debug (sorry, this isn't going to be fun to review, the diff is huge, but it is always the same changes)
26 lines
506 B
Rust
26 lines
506 B
Rust
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl};
|
|
|
|
use schema::blog_authors;
|
|
use {Error, Result};
|
|
|
|
#[derive(Clone, Queryable, Identifiable)]
|
|
pub struct BlogAuthor {
|
|
pub id: i32,
|
|
pub blog_id: i32,
|
|
pub author_id: i32,
|
|
pub is_owner: bool,
|
|
}
|
|
|
|
#[derive(Insertable)]
|
|
#[table_name = "blog_authors"]
|
|
pub struct NewBlogAuthor {
|
|
pub blog_id: i32,
|
|
pub author_id: i32,
|
|
pub is_owner: bool,
|
|
}
|
|
|
|
impl BlogAuthor {
|
|
insert!(blog_authors, NewBlogAuthor);
|
|
get!(blog_authors);
|
|
}
|