init
This commit is contained in:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user