File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed
crates/rs-tauri-vue/src-tauri/src/storage/sql Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -10,17 +10,16 @@ use tracing::info;
10
10
use crate :: { storage:: todo:: TodoSqlScope , util} ;
11
11
12
12
// sql storage biz
13
-
14
- pub struct AppSqlStorageBiz {
13
+ pub struct AppSqlStorage {
15
14
pub g : SqlConn ,
16
15
17
16
// biz units:
18
17
pub todo : TodoSqlScope ,
19
18
}
20
19
21
- impl AppSqlStorageBiz {
20
+ impl AppSqlStorage {
22
21
pub async fn new ( ) -> anyhow:: Result < Self > {
23
- let g = SqlConn :: default ( ) . await ? ;
22
+ let g = SqlConn :: default ( ) . await ;
24
23
25
24
let todo = TodoSqlScope :: new ( g. clone ( ) ) ;
26
25
@@ -33,6 +32,12 @@ pub struct SqlConn {
33
32
pub conn : SqlitePool ,
34
33
}
35
34
35
+ impl Clone for SqlConn {
36
+ fn clone ( & self ) -> Self {
37
+ Self { conn : self . conn . clone ( ) }
38
+ }
39
+ }
40
+
36
41
impl SqlConn {
37
42
pub async fn default ( ) -> Self {
38
43
let mut _root_dir = tauri:: api:: path:: document_dir ( ) ;
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ impl TodoSqlScope {
12
12
}
13
13
14
14
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 ?;
16
16
17
17
// Insert the task, then obtain the ID of this row
18
18
let id = sqlx:: query!(
You can’t perform that action at this time.
0 commit comments