Partially support DELETE /trips
Allow a user to delete a trip entry from the Trips table using the Primary Key. While this type-checks and compiles, it doesn't appear to be working as intended. Perhaps I should use an auto-incrementing integer as the Primary Key. I'm not sure how I want to handle this, so I'm punting for now.
This commit is contained in:
parent
0637da36cc
commit
6d9e76313d
3 changed files with 39 additions and 5 deletions
18
src/Types.hs
18
src/Types.hs
|
|
@ -199,6 +199,24 @@ instance FromRow Trip where
|
|||
<*> field
|
||||
<*> field
|
||||
|
||||
-- | The fields used as the Primary Key for a Trip entry.
|
||||
data TripPK = TripPK
|
||||
{ tripPKUsername :: Username
|
||||
, tripPKDestination :: Destination
|
||||
, tripPKStartDate :: Date
|
||||
} deriving (Eq, Show, Generic)
|
||||
|
||||
tripPKFields :: TripPK -> (Username, Destination, Date)
|
||||
tripPKFields (TripPK{ tripPKUsername
|
||||
, tripPKDestination
|
||||
, tripPKStartDate
|
||||
})
|
||||
= (tripPKUsername, tripPKDestination, tripPKStartDate)
|
||||
|
||||
-- TODO(wpcarro): Prefer shorter JSON fields like username instead of
|
||||
-- tripPKUsername.
|
||||
instance FromJSON TripPK
|
||||
|
||||
-- | Return the tuple representation of a Trip record for SQL.
|
||||
tripFields :: Trip -> (Username, Destination, Date, Date, Comment)
|
||||
tripFields (Trip{ tripUsername
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue