68 lines
1.5 KiB
Rust
68 lines
1.5 KiB
Rust
use chrono::prelude::*;
|
|
use diesel::prelude::*;
|
|
|
|
use crate::db::schema;
|
|
|
|
#[derive(Identifiable, Queryable, Debug)]
|
|
#[diesel(table_name = schema::configs)]
|
|
pub struct Config {
|
|
pub id: i32,
|
|
pub active: bool,
|
|
pub name: String,
|
|
pub description: String,
|
|
pub copyright: String,
|
|
pub owner_name: String,
|
|
pub owner_email: String,
|
|
pub owner_website: Option<String>,
|
|
}
|
|
|
|
#[derive(Insertable, Debug)]
|
|
#[diesel(table_name = schema::configs)]
|
|
pub struct NewConfig<'a> {
|
|
pub active: bool,
|
|
pub name: &'a str,
|
|
pub description: &'a str,
|
|
pub copyright: &'a str,
|
|
pub owner_name: &'a str,
|
|
pub owner_email: &'a str,
|
|
pub owner_website: Option<&'a str>,
|
|
}
|
|
|
|
#[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,
|
|
}
|