guys i got a little projet and i need to extrat de ID of the user from the Session.
I can't put it in a Text/Int because it says that the Session carry an Key (Sql Key i think) how can i converte it to Int to use in other methods from my project
I Tried to do it to recover the ID from session
getInicioR :: Handler Html
getInicioR = do
uid <- lookupSession "_ID"
user <- runDB $ get404 uid
Shows the follow error message:
Couldn't match expected type ‘Key t0’ with actual type ‘Maybe Text’
In the first argument of ‘get404’, namely ‘uid’
In the second argument of ‘($)’, namely ‘get404 uid’
Use
keyToValues
to get a list ofPersistValue
values.If you know, for instance, that the key is a Text value, then your list will consist of a single
PersistText
value and you could proceed like this: