From 83cc1905ad2900542dd7fd55cf6d2696ce0989f8 Mon Sep 17 00:00:00 2001 From: "Rene V. Vergara A." Date: Tue, 14 May 2024 18:17:21 -0400 Subject: [PATCH] rvv041 - CRUD operations for AddressBook completed delete record using AddressBookId --- src/Zenith/DB.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Zenith/DB.hs b/src/Zenith/DB.hs index 50d64f8..b3c25ce 100644 --- a/src/Zenith/DB.hs +++ b/src/Zenith/DB.hs @@ -1503,5 +1503,15 @@ updateAdrsInAdrBook pool a i = do set ab [AddressBookAddress =. val a] where_ $ ab ^. AddressBookId ==. val i +-- | delete an existing address from AddressBook +deleteAdrsFromAB :: ConnectionPool -> AddressBookId -> IO () +deleteAdrsFromAB pool i = do + runNoLoggingT $ + PS.retryOnBusy $ + flip PS.runSqlPool pool $ do + delete $ do + ab <- from $ table @AddressBook + where_ (ab ^. AddressBookId ==. val i) + rmdups :: Ord a => [a] -> [a] rmdups = map head . group . sort