Update
This commit is contained in:
parent
501b9d3093
commit
964534d0d9
21 changed files with 762 additions and 207 deletions
|
@ -10,8 +10,11 @@ pub mod models;
|
|||
pub mod schema;
|
||||
|
||||
pub type DbPool = Pool<ConnectionManager<PgConnection>>;
|
||||
pub type Connection = PgConnection;
|
||||
|
||||
pub fn establish_connection() -> ConnectionResult<PgConnection> {
|
||||
use diesel::Connection;
|
||||
|
||||
PgConnection::establish(&config::CONFIG.db_url)
|
||||
}
|
||||
|
||||
|
|
|
@ -52,3 +52,20 @@ pub struct UpdatePost<'a> {
|
|||
pub edited_at: Option<Option<NaiveDate>>,
|
||||
pub active: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Associations, Identifiable, Queryable, Debug)]
|
||||
#[diesel(belongs_to(Post))]
|
||||
#[diesel(belongs_to(Tag))]
|
||||
#[diesel(table_name = schema::post_tags)]
|
||||
pub struct PostTag {
|
||||
pub id: i32,
|
||||
pub post_id: i32,
|
||||
pub tag_id: i32,
|
||||
}
|
||||
|
||||
#[derive(Insertable, Debug)]
|
||||
#[diesel(table_name = schema::post_tags)]
|
||||
pub struct NewPostTag {
|
||||
pub post_id: i32,
|
||||
pub tag_id: i32,
|
||||
}
|
||||
|
|
|
@ -17,3 +17,11 @@ diesel::table! {
|
|||
active -> Bool,
|
||||
}
|
||||
}
|
||||
|
||||
diesel::table! {
|
||||
post_tags {
|
||||
id -> Integer,
|
||||
post_id -> Integer,
|
||||
tag_id -> Integer,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue