Address
state Text sqltype=varchar(255)
city Text sqltype=varchar(255)
street Text sqltype=varchar(255)
number Text sqltype=varchar(255)
deriving Show Typeable Eq
Location
name Text sqltype=varchar(255)
address AddressId sqltype=varchar(255)
UniqueLocationName name
deriving Show Typeable
Manifestation
name Text sqltype=varchar(255)
description Text Maybe sqltype=varchar(255)
category Category Maybe
startDateTime UTCTime sqltype=DateTime
location LocationId sqltype=varchar(255)
UniqueManName name
deriving Show Typeable
data Category = Sport | Concert | Theater
deriving (Show, Eq, Read, Enum, Bounded)
derivePersistField "Category"
What I want to do is to filter Manifestations, with the data I receive from users. Data for filtering is : [Category], city :: Text and search :: Text.
I imagined doing this with a selectList and its ability to filter items from the database but here I come up with one problem, so I would ask for help if anyone has an idea.
1. The first mistake is that my ManifestationCategory field is in the Maybe wrapper and I don't know way to handle this:
filterManifestations :: [Category] -> Maybe T.Text -> Maybe T.Text -> Handler [Entity Manifestation]
filterManifestations cat city src = do
let city' = fromMaybe city
src' = fromMaybe src
runDB $ selectList [ManifestationCategory <-. cat] []
-- Couldn't match type ‘Category’ with ‘Maybe Category’
arising from a use of ‘ManifestationCategory’
• In the first argument of ‘(<-.)’, namely ‘ManifestationCategory’
Of course any advice is welcome,
thanks,
Nemanja