25 lines
580 B
Rust
25 lines
580 B
Rust
use crate::schema::comments;
|
|
use diesel::prelude::*;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Queryable, Selectable, Serialize)]
|
|
#[diesel(table_name = comments)]
|
|
#[diesel(check_for_backend(diesel::sqlite::Sqlite))]
|
|
pub struct Comment {
|
|
pub id: i32,
|
|
pub author: String,
|
|
pub content: String,
|
|
}
|
|
|
|
#[derive(Insertable, Serialize, Deserialize)]
|
|
#[diesel(table_name = comments)]
|
|
pub struct NewComment<'a> {
|
|
pub author: &'a str,
|
|
pub content: &'a str,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct CreateCommentRequest {
|
|
pub author: String,
|
|
pub content: String,
|
|
}
|