2019-11-14 02:10:07 +00:00
|
|
|
use chrono::NaiveDateTime;
|
|
|
|
|
use serde::Serialize;
|
|
|
|
|
|
2019-12-18 09:20:00 +00:00
|
|
|
use super::schema::posts;
|
|
|
|
|
|
2025-04-11 06:41:14 +00:00
|
|
|
#[derive(Queryable, Selectable, Serialize)]
|
|
|
|
|
#[diesel(table_name = posts)]
|
|
|
|
|
#[diesel(check_for_backend(diesel::sqlite::Sqlite))]
|
2019-11-14 02:10:07 +00:00
|
|
|
pub struct Post {
|
|
|
|
|
pub id: i32,
|
|
|
|
|
pub title: String,
|
|
|
|
|
pub content: String,
|
|
|
|
|
pub published: bool,
|
2022-12-21 04:33:10 +00:00
|
|
|
pub views: i32,
|
2019-11-14 02:10:07 +00:00
|
|
|
pub created_at: NaiveDateTime,
|
|
|
|
|
pub updated_at: NaiveDateTime,
|
|
|
|
|
}
|
2019-12-18 09:20:00 +00:00
|
|
|
|
|
|
|
|
#[derive(FromForm, Insertable, Debug)]
|
2025-04-11 06:41:14 +00:00
|
|
|
#[diesel(table_name = posts)]
|
2019-12-18 09:20:00 +00:00
|
|
|
pub struct NewPost {
|
|
|
|
|
pub title: String,
|
|
|
|
|
pub content: String,
|
|
|
|
|
pub published: bool,
|
2022-12-21 04:33:10 +00:00
|
|
|
pub views: i32,
|
2019-12-18 09:20:00 +00:00
|
|
|
}
|