create DB::init function
semantically, its better to have function, that fully prepares db (connect and migrate)
This commit is contained in:
parent
29acb02a97
commit
09f7e76d96
@ -94,6 +94,13 @@ impl DB {
|
|||||||
.await?;
|
.await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn init<S: Into<String>>(db_url: S) -> Result<Self, mongodb::error::Error> {
|
||||||
|
let mut db = Self::new(db_url).await;
|
||||||
|
db.migrate().await?;
|
||||||
|
|
||||||
|
Ok(db)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user