2023-02-07 06:02:51 +00:00
|
|
|
use chrono::prelude::*;
|
|
|
|
use diesel::prelude::*;
|
|
|
|
|
|
|
|
use crate::db::schema;
|
|
|
|
|
|
|
|
#[derive(Identifiable, Queryable, Debug)]
|
|
|
|
#[diesel(table_name = schema::tags)]
|
|
|
|
pub struct Tag {
|
|
|
|
pub id: i32,
|
|
|
|
pub name: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Insertable, Debug)]
|
|
|
|
#[diesel(table_name = schema::tags)]
|
|
|
|
pub struct NewTag<'a> {
|
|
|
|
pub name: &'a str,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Identifiable, Queryable, Debug)]
|
|
|
|
#[diesel(table_name = schema::posts)]
|
|
|
|
pub struct Post {
|
|
|
|
pub id: i32,
|
|
|
|
pub name: String,
|
|
|
|
pub slug: String,
|
|
|
|
pub description: String,
|
|
|
|
pub content: String,
|
|
|
|
pub published_at: NaiveDate,
|
|
|
|
pub edited_at: Option<NaiveDate>,
|
|
|
|
pub active: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Insertable, Debug)]
|
|
|
|
#[diesel(table_name = schema::posts)]
|
|
|
|
pub struct NewPost<'a> {
|
|
|
|
pub name: &'a str,
|
|
|
|
pub slug: &'a str,
|
|
|
|
pub description: &'a str,
|
|
|
|
pub content: &'a str,
|
|
|
|
pub published_at: NaiveDate,
|
|
|
|
pub edited_at: Option<NaiveDate>,
|
|
|
|
pub active: bool,
|
|
|
|
}
|
2023-02-08 21:13:11 +00:00
|
|
|
|
|
|
|
#[derive(AsChangeset, Debug)]
|
|
|
|
#[diesel(table_name = schema::posts)]
|
|
|
|
pub struct UpdatePost<'a> {
|
|
|
|
pub name: Option<&'a str>,
|
|
|
|
pub slug: Option<&'a str>,
|
|
|
|
pub description: Option<&'a str>,
|
|
|
|
pub content: Option<&'a str>,
|
|
|
|
pub published_at: Option<NaiveDate>,
|
|
|
|
pub edited_at: Option<Option<NaiveDate>>,
|
|
|
|
pub active: Option<bool>,
|
|
|
|
}
|