Golden example: todo-rs (Axum + SQLx + SQLite)
This commit is contained in:
34
kipina-codebench/golden-examples/todo-rs/src/models.rs
Normal file
34
kipina-codebench/golden-examples/todo-rs/src/models.rs
Normal file
@@ -0,0 +1,34 @@
|
||||
//! Tietomallit — Todo, CreateTodo, UpdateTodo serde-rakenteina.
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Tehtävä — otsikko, kuvaus, deadline, prioriteetti ja status.
|
||||
#[derive(Debug, Serialize, Deserialize, sqlx::FromRow)]
|
||||
pub struct Todo {
|
||||
pub id: i64,
|
||||
pub title: String,
|
||||
pub description: Option<String>,
|
||||
pub due_date: Option<String>,
|
||||
pub priority: i64,
|
||||
pub status: String,
|
||||
}
|
||||
|
||||
/// Uuden tehtävän luonti. Pakolliset: title.
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct CreateTodo {
|
||||
pub title: String,
|
||||
pub description: Option<String>,
|
||||
pub due_date: Option<String>,
|
||||
pub priority: Option<i64>,
|
||||
pub status: Option<String>,
|
||||
}
|
||||
|
||||
/// Tehtävän päivitys — kaikki kentät valinnaisia.
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct UpdateTodo {
|
||||
pub title: Option<String>,
|
||||
pub description: Option<String>,
|
||||
pub due_date: Option<String>,
|
||||
pub priority: Option<i64>,
|
||||
pub status: Option<String>,
|
||||
}
|
||||
Reference in New Issue
Block a user