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<Runtime>,
});
let _ = self.tx.send(cmd);
}
+
+ pub fn get_notes<F>(&self, collection_id: i32, callback: F)
+ where F: FnOnce(Result<Vec<note::Model>, 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);
+ }
}