diff options
Diffstat (limited to 'src/index/app.rs')
| -rw-r--r-- | src/index/app.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/index/app.rs b/src/index/app.rs new file mode 100644 index 0000000..79f5a9a --- /dev/null +++ b/src/index/app.rs @@ -0,0 +1,24 @@ +use sqlx::sqlite::SqlitePool; + +use crate::{ + channel::repo::{Channel, Provider as _}, + error::BoxedError, +}; + +pub struct Index<'a> { + db: &'a SqlitePool, +} + +impl<'a> Index<'a> { + pub fn new(db: &'a SqlitePool) -> Self { + Self { db } + } + + pub async fn for_authenticated(&self) -> Result<Vec<Channel>, BoxedError> { + let mut tx = self.db.begin().await?; + let channels = tx.channels().all().await?; + tx.commit().await?; + + Ok(channels) + } +} |
