Skip to content

Commit

Permalink
Update seed script with a check if exists
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoPeters1024 committed Jan 10, 2022
1 parent b17fb43 commit 081d6c7
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Application/Script/SeedDatabase.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
module Application.Script.SeedDatabase where

import Application.Script.Prelude
import Control.Monad (void)

run :: Script
run = do
let route :: Route = newRecord { path = "panda", url = "https://www.youtube.com/watch?v=o-YBDTqX_ZU"}
route <- createRecord route
pure ()
route <- query @Route |> filterWhere (#path, "panda") |> fetchOneOrNothing

case route of
Just _ -> putStrLn "A recycled panda was already in place, disregard"
Nothing -> do
let route :: Route = newRecord { path = "panda", url = "https://www.youtube.com/watch?v=o-YBDTqX_ZU"}
void $ createRecord route


0 comments on commit 081d6c7

Please sign in to comment.