Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/SantaClaas/mealt. Mind melt OpenMLS, Tauri, SolidJS, axum experimentation
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637use libsql::{Builder, Connection, Database};use std::env;
// Use local database for debugging#[cfg(debug_assertions)]async fn create_database() -> Database { Builder::new_local("database.db").build().await.unwrap()}
#[cfg(not(debug_assertions))]async fn create_database() -> Database { let url = todo!("Set up loading secrets from Bitwarden"); let token = todo!("Set up loading secrets from Bitwarden");
Builder::new_remote(url, token) .build() .await .expect("Failed to connect to database")}
/// Creates the database and initializes it with the tablespub(super) async fn initialize_database() -> Connection { let database = create_database().await;
let connection = database.connect().unwrap();
let query = include_str!("./create_tables.sql"); connection .execute_batch(&query) .await .expect("Failed to create tables");
tracing::debug!("Tables created");
connection}