aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorJeremy Chone <jeremy.chone@gmail.com>2022-06-20 17:41:48 -0700
committerJeremy Chone <jeremy.chone@gmail.com>2022-06-20 17:41:48 -0700
commite365f3cc197f020afa3909490530c55f7beaa51e (patch)
tree8977d9418437bf9e4737d63eb1802bdcd5aded9c /README.md
parent5ffb5c1d55397162a419945eb81b942fad6603fc (diff)
downloadFlightCore-e365f3cc197f020afa3909490530c55f7beaa51e.tar.gz
FlightCore-e365f3cc197f020afa3909490530c55f7beaa51e.zip
. add sqlx state as example
Diffstat (limited to 'README.md')
-rw-r--r--README.md29
1 files changed, 27 insertions, 2 deletions
diff --git a/README.md b/README.md
index 2f5b98ff..272d2dae 100644
--- a/README.md
+++ b/README.md
@@ -13,7 +13,32 @@ npm install
# terminal 1 (UI localhost for hot-reload)
npm run ui-dev
-# terminal 2 (for the Tauri ho)
-npm
+# terminal 2 (for the Rust/App hot-reload)
+npm run tauri dev
```
+## Database Pool as state
+
+Rather to have a simple Mutex for the state, database can be used.
+
+```
+sqlx = { version = "0.6", features = [ "runtime-tokio-rustls", "postgres" ] }
+```
+
+```rs
+let con_string = format!("postgres://postgres:postgres@localhost/postgres");
+let db = PgPoolOptions::new()
+ .max_connections(5)
+ .connect(&con_string)
+ .await
+ .expect("Cannot create PgPool");
+
+let arc_db = Arc::new(db);
+```
+
+Then
+
+```rs
+tauri::Builder::default()
+ .manage(arc_db)
+``` \ No newline at end of file