use crate::error::Result;
use crate::services::transaction::adapter::MongodbTransaction;
#[derive(Clone)]
pub struct TransactionRepository {
adapter: MongodbTransaction,
}
impl TransactionRepository {
pub fn new(adapter: MongodbTransaction) -> Self {
Self { adapter }
}
}
impl TransactionRepository {
pub async fn start_transactions(&self) -> Result<mongodb::ClientSession> {
let session = self.adapter.start_transaction().await?;
Ok(session)
}
pub async fn commit_transaction(&self, session: mongodb::ClientSession) -> Result<()> {
self.adapter.commit_transaction(session).await?;
Ok(())
}
}