codigocomentado/src/models.rs

27 lines
590 B
Rust
Raw Normal View History

2019-11-14 02:10:07 +00:00
use chrono::NaiveDateTime;
use serde::Serialize;
use super::schema::posts;
#[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,
}
#[derive(FromForm, Insertable, Debug)]
#[diesel(table_name = posts)]
pub struct NewPost {
pub title: String,
pub content: String,
pub published: bool,
2022-12-21 04:33:10 +00:00
pub views: i32,
}