From 08d3a9f867bd92dafa3dc5ccc61254d25993130e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kier=C3=A1n=20Meinhardt?= Date: Fri, 11 Oct 2024 16:53:42 +0200 Subject: autogenerate collection item IDs --- backend/lib/ACMS/API/REST/Collection.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'backend/lib') diff --git a/backend/lib/ACMS/API/REST/Collection.hs b/backend/lib/ACMS/API/REST/Collection.hs index bfbd637..ed0ae9a 100644 --- a/backend/lib/ACMS/API/REST/Collection.hs +++ b/backend/lib/ACMS/API/REST/Collection.hs @@ -8,6 +8,8 @@ import Data.Function ((&)) import Data.Text qualified as T import Network.HTTP.Simple import Text.Printf (printf) +import Data.UUID qualified as U +import Data.UUID.V4 qualified as U type CollectionName = T.Text @@ -37,8 +39,10 @@ update c i o = & httpLBS >>= A.throwDecode . getResponseBody -create :: T.Text -> T.Text -> A.Object -> IO () -create c i o = +create :: T.Text -> A.Object -> IO () +create c o = do + uuid <- U.nextRandom + let i = U.toText uuid <> ".json" "http://localhost:8081" & setRequestMethod "POST" & setRequestBodyLBS -- cgit v1.2.3