This commit is contained in:
2026-07-27 09:15:28 +02:00
parent d0e4bdd90e
commit 70c0b649e6
6 changed files with 62 additions and 7 deletions
+11
View File
@@ -21,6 +21,17 @@ impl ChannelRepository {
Ok(channel::Entity::find().all(&self.context.db).await?)
}
pub async fn filter(&self, server_id: Option<Uuid>, category_id: Option<Uuid>) -> AnyResult<Vec<channel::Model>> {
let mut query = channel::Entity::find();
if let Some(s_id) = server_id {
query = query.filter(channel::Column::ServerId.eq(s_id));
}
if let Some(c_id) = category_id {
query = query.filter(channel::Column::CategoryId.eq(c_id));
}
Ok(query.all(&self.context.db).await?)
}
pub async fn update(&self, active: channel::ActiveModel) -> AnyResult<channel::Model> {
let channel = active.update(&self.context.db).await?;
self.context.events.emit("channel_updated", channel.clone());