blob: fabf35cd4b754e6540b2cb6e9d4fd563a5611d06 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
use sqlx::sqlite::SqlitePool;
use crate::{
channel::repo::channels::{Channel, Id as ChannelId, Provider as _},
error::BoxedError,
};
pub struct Index<'a> {
db: &'a SqlitePool,
}
impl<'a> Index<'a> {
pub const fn new(db: &'a SqlitePool) -> Self {
Self { db }
}
pub async fn channel(&self, channel: ChannelId) -> Result<Channel, BoxedError> {
let mut tx = self.db.begin().await?;
let channel = tx.channels().by_id(channel).await?;
tx.commit().await?;
Ok(channel)
}
}
|