Initial Commit

This commit is contained in:
Paul Makles
2020-01-19 11:55:14 +00:00
commit 8c41a0d00c
8 changed files with 2085 additions and 0 deletions

17
src/database.rs Normal file
View File

@@ -0,0 +1,17 @@
use mongodb::Client;
use std::env;
use once_cell::sync::OnceCell;
static DBCONN: OnceCell<Client> = OnceCell::new();
pub fn connect() {
let client = Client::with_uri_str(
&env::var("DB_URI").expect("DB_URI not in environment variables!"))
.expect("Failed to init db connection.");
DBCONN.set(client).unwrap();
}
pub fn get_connection() -> &'static Client {
DBCONN.get().unwrap()
}