feat(sql): improved sqlite load path

pull/2487/head
w33d 5 months ago
parent 1ac32b8be9
commit 058df10590

@ -68,17 +68,11 @@ export default class Database {
*
* # Sqlite
*
* The path is relative to `tauri::path::BaseDirectory::App` by default and must start with `sqlite:`.
* The path is relative to `tauri::path::BaseDirectory::App` and must start with `sqlite:`.
*
* @example
* ```ts
* // for relative path
* const db = await Database.get("sqlite:test.db");
* ```
* @example
* ```ts
* // for absolute path
* const db = await Database.get("sqlite:/home/ubuntu/test.db");
* const db = Database.get("sqlite:test.db");
* ```
*/
static get(path: string): Database {

@ -4,7 +4,6 @@
#[cfg(feature = "sqlite")]
use std::fs::create_dir_all;
use std::path::Path;
use indexmap::IndexMap;
use serde_json::Value as JsonValue;
@ -77,7 +76,7 @@ impl DbPool {
{
#[cfg(feature = "sqlite")]
"sqlite" => {
let conn_url = if Path::new(conn_url).is_absolute() {
let conn_url = if std::path::Path::new(conn_url).is_absolute() {
create_dir_all(conn_url).expect("Couldn't create dir");
conn_url

Loading…
Cancel
Save