2020-05-28 13:28:58 -07:00
|
|
|
use mongodb::options::ClientOptions;
|
|
|
|
|
use mongodb::Client;
|
|
|
|
|
use mongodb::error::Error;
|
2020-05-14 22:53:22 -07:00
|
|
|
|
2020-05-28 13:28:58 -07:00
|
|
|
pub async fn connect() -> Result<Client, Error> {
|
|
|
|
|
info!("Initializing database connection");
|
2020-05-14 22:53:22 -07:00
|
|
|
|
2020-05-28 13:28:58 -07:00
|
|
|
let mut client_options = ClientOptions::parse("mongodb://localhost:27017").await?;
|
|
|
|
|
client_options.app_name = Some("Actix Web Server".to_string());
|
|
|
|
|
|
|
|
|
|
Client::with_options(client_options)
|
2020-05-27 20:46:59 +02:00
|
|
|
}
|