diff --git a/backend/src/models/customer.rs b/backend/src/models/customer.rs index f41bd69..9741a73 100644 --- a/backend/src/models/customer.rs +++ b/backend/src/models/customer.rs @@ -63,14 +63,30 @@ impl CrudBackend for Customer { conn: impl sqlx::prelude::Executor<'a, Database = sqlx::Postgres>, id: Self::Identifier, ) -> Result { - todo!() + sqlx::query_as!(Customer, r#"SELECT * FROM customers WHERE id = $1"#, id) + .fetch_one(conn) + .await + .map_err(Into::into) } async fn update_inner(&mut self, conn: &mut PgConnection) -> Result<()> { - todo!() + sqlx::query!( + r#"UPDATE customers SET name = $1, code = $2 WHERE id = $3"#, + self.name, + self.code, + self.id + ) + .execute(conn) + .await + .map_err(Into::into) + .map(|_| ()) } async fn delete_inner(&self, conn: &mut PgConnection) -> Result<()> { - todo!() + sqlx::query!(r#"DELETE FROM customers WHERE id = $1"#, self.id) + .execute(conn) + .await + .map_err(Into::into) + .map(|_| ()) } }