我的模型中有:
Email
email Text
user UserId Maybe
verkey Text Maybe
UniqueEmail email
我有一个表格,用户可以在其中输入电子邮件(现有用户的)和金额(int)。根据这封电子邮件,我想找到该用户的 UserId。我到目前为止:
paymentForm :: Form Payment
paymentForm = renderDivs $ Payment
<$> lift (liftIO getCurrentTime)
<*> pure userId
<*> areq userIdField "To" Nothing
<*> areq intField "Amount" Nothing
where
message :: Text
message = "This user doesnt exist"
userIdField = check hisUserId emailField
hisUserId x | rawSql (SELECT user FROM "Email" WHERE "Email".email = x) == "" = Left message
| otherwise = Right x
但这似乎不起作用。有任何想法吗?