framework_cqrs_lib/cqrs/infra/daos/
database_mongo.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use mongodb::{Client, Database};

pub struct DatabaseMongo {
    pub underlying: Database,
}

impl DatabaseMongo {
    pub async fn new(dbname: &str) -> Self {
        let uri = std::env::var("MONGO_URI").unwrap();
        let client: Client = Client::with_uri_str(uri.clone()).await.unwrap();
        let db: Database = client.database(dbname);
        Self {
            underlying: db
        }
    }
}