summaryrefslogtreecommitdiff
path: root/src/channel/repo/channels.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/channel/repo/channels.rs')
-rw-r--r--src/channel/repo/channels.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/channel/repo/channels.rs b/src/channel/repo/channels.rs
index 6fb0c23..fc52aa3 100644
--- a/src/channel/repo/channels.rs
+++ b/src/channel/repo/channels.rs
@@ -44,6 +44,22 @@ impl<'c> Channels<'c> {
Ok(channel)
}
+ pub async fn by_id(&mut self, channel: Id) -> Result<Channel, BoxedError> {
+ let channel = sqlx::query_as!(
+ Channel,
+ r#"
+ select id as "id: Id", name
+ from channel
+ where id = $1
+ "#,
+ channel,
+ )
+ .fetch_one(&mut *self.0)
+ .await?;
+
+ Ok(channel)
+ }
+
pub async fn all(&mut self) -> Result<Vec<Channel>, BoxedError> {
let channels = sqlx::query_as!(
Channel,