From d02c1fa314da8afc4d8dea44a2bb689f3af2262d Mon Sep 17 00:00:00 2001 From: Nico Date: Tue, 28 Oct 2025 20:34:10 +0100 Subject: [PATCH] updated structs a bit --- src-tauri/Cargo.lock | 3 +++ src-tauri/Cargo.toml | 1 + src-tauri/src/models/node.rs | 1 + src-tauri/src/models/path.rs | 17 +++++++++++++---- src-tauri/src/repositories/path_repository.rs | 2 +- src/interfaces/Path.ts | 4 ++-- 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index e931321..402496f 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -496,8 +496,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "145052bdd345b87320e369255277e3fb5152762ad123a901ef5c262dd38fe8d2" dependencies = [ "iana-time-zone", + "js-sys", "num-traits", "serde", + "wasm-bindgen", "windows-link 0.2.0", ] @@ -1030,6 +1032,7 @@ checksum = "7fd99930f64d146689264c637b5af2f0233a933bef0d8570e2526bf9e083192d" name = "flalingo" version = "0.1.0" dependencies = [ + "chrono", "serde", "serde_json", "sqlx", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index d6e7da8..6bde87f 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -26,4 +26,5 @@ serde_json = "1" # SQLx und Tokio für asynchrone DB-Zugriffe sqlx = { version = "0.8.6", features = ["runtime-tokio-rustls", "sqlite", "macros", "migrate"] } tokio = { version = "1", features = ["full"] } +chrono = "0.4.42" diff --git a/src-tauri/src/models/node.rs b/src-tauri/src/models/node.rs index c6469c3..580d426 100644 --- a/src-tauri/src/models/node.rs +++ b/src-tauri/src/models/node.rs @@ -1,3 +1,4 @@ +#[derive(Debug, sqlx::FromRow)] pub struct Node { id: u32, title: String, diff --git a/src-tauri/src/models/path.rs b/src-tauri/src/models/path.rs index f57507b..9e8ca81 100644 --- a/src-tauri/src/models/path.rs +++ b/src-tauri/src/models/path.rs @@ -1,12 +1,21 @@ +use chrono::{DateTime, Utc}; +use sqlx::sqlite::SqliteRow; +use sqlx::Row; -#[derive(Debug, sqlx::FromRow)] +use crate::models::node::Node; + +#[derive(sqlx::FromRow, Debug)] pub struct Path { id: String, title: String, description: String, + nodes: Vec, + metadata: Metadata, } -pub struct PathVersions { - path_id: String, - version_number: String, +#[derive(Debug, sqlx::FromRow)] +pub struct Metadata { + versions: Vec, + created_at: DateTime, + updated_at: DateTime, } diff --git a/src-tauri/src/repositories/path_repository.rs b/src-tauri/src/repositories/path_repository.rs index 2eee7a2..c0fe09b 100644 --- a/src-tauri/src/repositories/path_repository.rs +++ b/src-tauri/src/repositories/path_repository.rs @@ -1,4 +1,4 @@ -use sqlx::{pool, sqlite::SqlitePool, FromRow}; +use sqlx::{sqlite::SqlitePool, FromRow}; use crate::models::path::Path; diff --git a/src/interfaces/Path.ts b/src/interfaces/Path.ts index 23ec398..2ede545 100644 --- a/src/interfaces/Path.ts +++ b/src/interfaces/Path.ts @@ -1,5 +1,5 @@ interface Path { - id: number, + id: string, title: string, description: string, nodes: Node[], @@ -8,4 +8,4 @@ interface Path { createdAt: Date, updatedAt: Date, } -} \ No newline at end of file +}