use tokio::sync::broadcast::error::SendError;
use migration::{Expr, Migrator, MigratorTrait};
-use entity::{collection, filecontent, note, notecontent, profile, repository};
+use entity::{attachment, collection, filecontent, note, notecontent, profile, repository};
use entity::profile::Entity as Profile;
use entity::collection::{create_notebook_hierarchy, CollectionType, Entity as Collection, Node};
use entity::note::{Column, Entity as Note, NoteType};
});
let _ = self.tx.send(cmd);
}
+
+ pub fn get_note_attachments<F>(&self, note_id: i32, callback: F)
+ where F: FnOnce(Result<Vec<attachment::Model>, DbErr>) + Send + 'static {
+ let backend = self.backend.clone();
+ let cmd = Box::pin(async move {
+ let attachments = attachment::Entity::find()
+ .filter(attachment::Column::NoteId.eq(note_id))
+ .all(&backend.db).await;
+ callback(attachments);
+ });
+ let _ = self.tx.send(cmd);
+ }
pub fn open_extern<F>(&self, note_id: i32, callback: F)
where F: FnOnce(OpenExternResult) + Send + 'static {