init
This commit is contained in:
@@ -15,6 +15,10 @@ impl ChannelRepository {
|
||||
.await?)
|
||||
}
|
||||
|
||||
pub async fn get_all(&self) -> AnyResult<Vec<channel::Model>> {
|
||||
Ok(channel::Entity::find().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());
|
||||
@@ -27,11 +31,11 @@ impl ChannelRepository {
|
||||
Ok(channel)
|
||||
}
|
||||
|
||||
pub async fn delete(&self, id: uuid::Uuid) -> AnyResult<()> {
|
||||
channel::Entity::delete_by_id(id)
|
||||
pub async fn delete(&self, id: uuid::Uuid) -> AnyResult<bool> {
|
||||
let res = channel::Entity::delete_by_id(id)
|
||||
.exec(&self.context.db)
|
||||
.await?;
|
||||
self.context.events.emit("channel_deleted", id);
|
||||
Ok(())
|
||||
Ok(res.rows_affected > 0)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user