Add delete endpoints and clean up filters

This commit is contained in:
2020-07-29 00:02:48 -04:00
parent 17cd3f12d2
commit 79b45551fd
7 changed files with 106 additions and 55 deletions

View File

@@ -62,6 +62,13 @@ impl Model for Shop {
.await?)
}
#[instrument(level = "debug", skip(db))]
async fn delete(db: &PgPool, id: i32) -> Result<u64> {
Ok(sqlx::query!("DELETE FROM shops WHERE id = $1", id)
.execute(db)
.await?)
}
#[instrument(level = "debug", skip(db))]
async fn list(db: &PgPool, list_params: ListParams) -> Result<Vec<Self>> {
let result = if let Some(order_by) = list_params.get_order_by() {