From 5dd363d7396bbecb722d6a3f5b3a9fa1038e7861 Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Thu, 21 May 2026 21:22:34 +0200 Subject: [PATCH] add get_notes backend function --- application/src/backend.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/application/src/backend.rs b/application/src/backend.rs index 8644692..4050344 100644 --- a/application/src/backend.rs +++ b/application/src/backend.rs @@ -7,9 +7,10 @@ use tokio::sync::{broadcast, mpsc}; use migration::{Migrator, MigratorTrait}; use ui_rs::ui; -use entity::{collection, profile}; +use entity::{collection, note, profile}; use entity::profile::Entity as Profile; use entity::collection::{create_notebook_hierarchy, CollectionType, Entity as Collection, Node}; +use entity::note::{Entity as Note}; pub struct Backend { rt: Arc, @@ -252,4 +253,16 @@ impl BackendHandle { }); let _ = self.tx.send(cmd); } + + pub fn get_notes(&self, collection_id: i32, callback: F) + where F: FnOnce(Result, DbErr>) + Send + 'static { + let backend = self.backend.clone(); + let cmd = Box::pin(async move { + let result = Note::find() + .filter(note::Column::CollectionId.eq(collection_id)) + .order_by_id_asc().all(&backend.db).await; + callback(result); + }); + let _ = self.tx.send(cmd); + } } -- 2.47.3