create BotInstance::get_by_name

This commit is contained in:
Akulij 2025-05-31 10:30:03 +05:00
parent bc2397a32c
commit 102fae25c7

View File

@ -48,4 +48,10 @@ impl BotInstance {
Ok(bi.find(doc! {}).await?.try_collect().await?) Ok(bi.find(doc! {}).await?.try_collect().await?)
} }
pub async fn get_by_name<D: CallDB>(db: &mut D, name: &str) -> DbResult<Option<Self>> {
let bi = db.get_collection::<Self>().await;
Ok(bi.find_one(doc! {"name": name}).await?)
}
} }