From: Olaf Wintermann Date: Thu, 21 May 2026 19:22:34 +0000 (+0200) Subject: add get_notes backend function X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=HEAD;p=note.git add get_notes backend function --- 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); + } }