Commit ef4cd1ee authored by MrMan's avatar MrMan

Working delete by UUID

parent 9bc8529d
......@@ -35,11 +35,13 @@ type TodoAPI =
"todos" :> Get '[JSON] [WithUUID Task]
:<|> "todos" :> Capture "uuid" UUID :> Get '[JSON] (WithUUID Task)
:<|> "todos" :> Capture "uuid" UUID :> ReqBody '[JSON] (Partial TaskF) :> Patch '[JSON] (WithUUID Task)
:<|> "todos" :> Capture "uuid" UUID :> Delete '[JSON] (WithUUID Task)
todoServer :: ServerT TodoAPI AppHandler
todoServer = listTodos
:<|> getTodoByUUID
:<|> patchTodoByUUID
:<|> deleteTodoByUUID
listTodos :: AppHandler [WithUUID Task]
listTodos = ask
......@@ -59,6 +61,11 @@ patchTodoByUUID uuid partial = pure (validate partial)
>>= rightOrConvertToServantErr
>>= pure . (toTaskFromF <$>)
deleteTodoByUUID :: UUID -> AppHandler (WithUUID Task)
deleteTodoByUUID uuid = ask
>>= \(AppState _ estore) -> liftIO (deleteByUUID estore uuid :: IO (Either EntityStoreError (WithUUID Task)))
>>= rightOrServantErr genericServerError
todoAPI :: Proxy TodoAPI
todoAPI = Proxy
......
......@@ -299,9 +299,14 @@ instance SQLUpdatable (Partial (TaskFInState state)) where
data QueryWithParams p = QWP Query p
instance forall (state :: TaskState). SQLDeletable (TaskFInState state) where
instance SQLDeletable Task where
deletionMode = Hard
instance forall (state :: TaskState). SQLDeletable (TaskFInState state) where
deletionMode = case (deletionMode :: DeletionMode Task) of
Hard -> Hard
Soft -> Soft
instance SQLDeletable a => SQLDeletable (Complete a) where
deletionMode = case (deletionMode :: DeletionMode a) of
Hard -> Hard
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment