From 74e9daeddb2a3d136a2c711e58729ac666a827a8 Mon Sep 17 00:00:00 2001 From: yggverse Date: Thu, 14 Nov 2024 08:28:24 +0200 Subject: [PATCH] implements records getter --- src/profile/bookmark/database.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/profile/bookmark/database.rs b/src/profile/bookmark/database.rs index cd4d2573..0d2cda21 100644 --- a/src/profile/bookmark/database.rs +++ b/src/profile/bookmark/database.rs @@ -23,6 +23,14 @@ impl Database { profile_id, } } + + // Getters + + pub fn records(&self, request: Option<&str>) -> Vec { + let readable = self.connection.read().unwrap(); + let tx = readable.unchecked_transaction().unwrap(); + select(&tx, self.profile_id, request).unwrap() + } } // Low-level DB API @@ -59,7 +67,7 @@ pub fn insert( pub fn select( tx: &Transaction, profile_id: i64, - request: Option, + request: Option<&str>, ) -> Result, Error> { let mut stmt = tx.prepare( "SELECT `id`, `profile_id`, `time`, `request` @@ -69,7 +77,7 @@ pub fn select( let filter = match request { Some(value) => value, - None => format!("%"), + None => "%", }; let result = stmt.query_map((profile_id, filter), |row| {