feat: added backend for site comments
This commit is contained in:
parent
4b1a899f05
commit
af3dfba510
12 changed files with 359 additions and 2 deletions
25
src/models.rs
Normal file
25
src/models.rs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
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,
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue