【发布时间】:2013-11-22 06:08:41
【问题描述】:
我的模型中有:
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
但这似乎不起作用。有什么想法吗?
【问题讨论】:
-
我认为您使用了错误的表格,电子邮件存储在用户中