I am a beginner in Hashkell and Yesod, and I am interested in how to take all the unique values
from one column in the mysql table.
A concrete example is that I have an Address entity and I want to take all the values for the city attribute :
Address json
state Text sqltype=varchar(255)
city Text sqltype=varchar(255)
street Text Maybe sqltype=varchar(255)
number Text sqltype=varchar(255)
deriving Show Typeable
I want to pick up all the values of the city to use them in the form.
I would like to have these values in the dropdown list:
filters <- runInputPost $ ManFilter
<$> iopt (selectFieldList city) "City"
defaultLayout [whamlet | <h1> # {show $ filters} |]
where
city :: [(Text, Text)]
city = [("NY", "NY"), ("London", "London"), ("Madrid", "Madrid")]
And another question how to automatically create a tuple city :: [(Text, Text)]
from the
values I would get from the database?
If anyone can help I would be grateful, because I'm pretty stuck with the forms.
Also write if it is a good procedure, what is wrong and of course any advice is welcome.
Thank you!