summaryrefslogtreecommitdiff
path: root/src/channel/app.rs
blob: 84822cb6abfbc516b8ea4e1bd84a812d9d6f23ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use sqlx::sqlite::SqlitePool;

use super::repo::Provider as _;
use crate::error::BoxedError;

pub struct Channels<'a> {
    db: &'a SqlitePool,
}

impl<'a> Channels<'a> {
    pub fn new(db: &'a SqlitePool) -> Self {
        Self { db }
    }

    pub async fn create(&self, name: &str) -> Result<(), BoxedError> {
        let mut tx = self.db.begin().await?;
        tx.channels().create(name).await?;
        tx.commit().await?;
        Ok(())
    }
}