From f535df6da4f2150f0b6dc2ced4bd09b6512bc205 Mon Sep 17 00:00:00 2001 From: itsscb Date: Sun, 4 May 2025 22:57:19 +0200 Subject: [PATCH] feat: improve list_scripts to return actual Vec<(Uuid, Script)> --- src/db.rs | 61 +++++++++++++++++++++++++++++++++++---------------- src/script.rs | 5 +++-- 2 files changed, 45 insertions(+), 21 deletions(-) diff --git a/src/db.rs b/src/db.rs index de344e2..beaeb8c 100644 --- a/src/db.rs +++ b/src/db.rs @@ -1,7 +1,7 @@ -use sqlx::{SqlitePool, migrate::Migrator}; +use sqlx::{SqlitePool, migrate::Migrator, prelude::FromRow}; use uuid::Uuid; -use crate::script::Script; +use crate::script::{Parameter, Script}; static MIGRATOR: Migrator = sqlx::migrate!("./migrations"); @@ -49,26 +49,51 @@ pub async fn add_script(pool: &SqlitePool, script: &Script) -> Result<(), String Ok(()) } +#[derive(FromRow, Debug)] +struct ScriptRow { + id: String, + name: String, + path: String, + parameters: String, + default_parameter_set: Option, + help_uri: Option, + supports_paging: Option, + supports_should_process: Option, + positional_binding: Option, +} + // TODO: Return Vec