summaryrefslogtreecommitdiff
path: root/src/channel/app.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/channel/app.rs')
-rw-r--r--src/channel/app.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/channel/app.rs b/src/channel/app.rs
new file mode 100644
index 0000000..84822cb
--- /dev/null
+++ b/src/channel/app.rs
@@ -0,0 +1,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(())
+ }
+}