create MessageForward.store_db to store by DB type

reason: easier to use with RwLock
This commit is contained in:
Akulij 2025-05-31 13:45:45 +05:00
parent 2e447e87fd
commit b8d07d0ad5

View File

@ -2,6 +2,7 @@ use bson::doc;
use serde::{Deserialize, Serialize};
use super::DbResult;
use super::DB;
use crate::query_call_consume;
use crate::CallDB;
@ -42,6 +43,15 @@ impl MessageForward {
Ok(self)
});
pub async fn store_db(self, db: &mut DB) -> DbResult<Self> {
let db = db.get_database().await;
let ci = db.collection::<Self>("message_forward");
ci.insert_one(&self).await?;
Ok(self)
}
pub async fn get<D: CallDB>(
db: &mut D,
chat_id: i64,