simple-live-chat/src/db.rs

11 lines
268 B
Rust
Raw Normal View History

2021-07-29 21:44:34 +00:00
use std::sync::Mutex;
use once_cell::sync::Lazy;
use sled::Db;
pub static DB: Lazy<Mutex<Db>> = Lazy::new(|| {
let db_path = std::env::var("DB_PATH").unwrap_or_else(|_| "user-database.db".to_string());
Mutex::new(sled::open(db_path).unwrap())
});