Add delete endpoints and clean up filters
This commit is contained in:
@@ -55,7 +55,7 @@ impl Model for InteriorRefList {
|
||||
)
|
||||
}
|
||||
|
||||
#[instrument(level = "debug", skip(db))]
|
||||
#[instrument(level = "debug", skip(self, db))]
|
||||
async fn save(self, db: &PgPool) -> Result<Self> {
|
||||
// TODO:
|
||||
// * Decide if I'll need to make the same changes to merchandise and transactions
|
||||
@@ -74,6 +74,15 @@ impl Model for InteriorRefList {
|
||||
.await?)
|
||||
}
|
||||
|
||||
#[instrument(level = "debug", skip(db))]
|
||||
async fn delete(db: &PgPool, id: i32) -> Result<u64> {
|
||||
Ok(
|
||||
sqlx::query!("DELETE FROM interior_ref_lists 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() {
|
||||
|
||||
@@ -24,8 +24,6 @@ where
|
||||
}
|
||||
async fn get(db: &PgPool, id: i32) -> Result<Self>;
|
||||
async fn save(self, db: &PgPool) -> Result<Self>;
|
||||
async fn delete(db: &PgPool, id: i32) -> Result<u64>;
|
||||
async fn list(db: &PgPool, list_params: ListParams) -> Result<Vec<Self>>;
|
||||
async fn bulk_save(_db: &PgPool, _models: Vec<Self>) -> Result<()> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,13 @@ impl Model for Owner {
|
||||
.await?)
|
||||
}
|
||||
|
||||
#[instrument(level = "debug", skip(db))]
|
||||
async fn delete(db: &PgPool, id: i32) -> Result<u64> {
|
||||
Ok(sqlx::query!("DELETE FROM owners 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() {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user