name = "note"
version = "0.1.0"
dependencies = [
+ "entity",
+ "migration",
"sea-orm",
"tokio",
"ui-rs",
[dependencies]
ui-rs = { path = "../ui-rs" }
+entity = { path = "../entity" }
+migration = { path = "../migration" }
sea-orm = { version = "2.0.0-rc", features = [ "sqlx-sqlite", "sqlx-postgres", "runtime-tokio-native-tls", "macros" ] }
tokio = { version = "1.52.1", features = ["rt-multi-thread"] }
-use sea_orm::{Database, DatabaseConnection};
+use sea_orm::{Database, DatabaseConnection, DbErr};
use tokio::runtime::Runtime;
use std::sync::Arc;
+use migration::{Migrator, MigratorTrait};
use ui_rs::ui;
pub struct Backend {
Self { rt, db }
}
+
+ pub fn migrate(&self) -> Result<(), DbErr> {
+ self.rt.block_on(async {
+ Migrator::up(&self.db, None).await
+ })?;
+
+ Ok(())
+ }
}
ui::app_init("note");
let backend = Backend::new();
+ backend.migrate().unwrap(); // todo: check error
+
let mut app = App { backend: backend };
ui::app_run::<MainWindow>(&mut app);
}
pub fn get_label(&self) -> String {
unsafe {
- let cstr_ptr = unsafe { ui_linkbutton_get_label(self.ptr) };
+ let cstr_ptr = ui_linkbutton_get_label(self.ptr);
if cstr_ptr.is_null() {
return String::new();
}
pub fn get_uri(&self) -> String {
unsafe {
- let cstr_ptr = unsafe { ui_linkbutton_get_uri(self.ptr) };
+ let cstr_ptr = ui_linkbutton_get_uri(self.ptr);
if cstr_ptr.is_null() {
return String::new();
}