Skip to content

Commit e010975

Browse files
committed
update
1 parent d45d83d commit e010975

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

crates/rs-tauri-vue/src-tauri/src/storage/sql/db.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,16 @@ use tracing::info;
1010
use crate::{storage::todo::TodoSqlScope, util};
1111

1212
// sql storage biz
13-
14-
pub struct AppSqlStorageBiz {
13+
pub struct AppSqlStorage {
1514
pub g: SqlConn,
1615

1716
// biz units:
1817
pub todo: TodoSqlScope,
1918
}
2019

21-
impl AppSqlStorageBiz {
20+
impl AppSqlStorage {
2221
pub async fn new() -> anyhow::Result<Self> {
23-
let g = SqlConn::default().await?;
22+
let g = SqlConn::default().await;
2423

2524
let todo = TodoSqlScope::new(g.clone());
2625

@@ -33,6 +32,12 @@ pub struct SqlConn {
3332
pub conn: SqlitePool,
3433
}
3534

35+
impl Clone for SqlConn {
36+
fn clone(&self) -> Self {
37+
Self { conn: self.conn.clone() }
38+
}
39+
}
40+
3641
impl SqlConn {
3742
pub async fn default() -> Self {
3843
let mut _root_dir = tauri::api::path::document_dir();

crates/rs-tauri-vue/src-tauri/src/storage/sql/todo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ impl TodoSqlScope {
1212
}
1313

1414
pub async fn add_todo(&self, todo: &TodoEntity) -> anyhow::Result<i64> {
15-
let mut conn = self.g.conn.acquire().await?;
15+
let mut conn = (self.g).conn.acquire().await?;
1616

1717
// Insert the task, then obtain the ID of this row
1818
let id = sqlx::query!(

0 commit comments

Comments
 (0)