forked from jmug/stoatchat
Switch to async Rust and break all logic.
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
use crate::util::variables::MONGO_URI;
|
||||
|
||||
use mongodb::sync::{Client, Collection, Database};
|
||||
use mongodb::{Client, Collection, Database};
|
||||
use once_cell::sync::OnceCell;
|
||||
|
||||
static DBCONN: OnceCell<Client> = OnceCell::new();
|
||||
|
||||
pub fn connect() {
|
||||
let client = Client::with_uri_str(&MONGO_URI).expect("Failed to init db connection.");
|
||||
pub async fn connect() {
|
||||
let client = Client::with_uri_str(&MONGO_URI)
|
||||
.await
|
||||
.expect("Failed to init db connection.");
|
||||
|
||||
DBCONN.set(client).unwrap();
|
||||
migrations::run_migrations();
|
||||
migrations::run_migrations().await;
|
||||
}
|
||||
|
||||
pub fn get_connection() -> &'static Client {
|
||||
|
||||
Reference in New Issue
Block a user