【发布时间】:2017-09-06 15:14:12
【问题描述】:
我正在使用 Yesod 开发我的第一个应用程序,并且我正在创建一些 CRUD api 来启动。
我有一个看起来像的模型
User json
...
Activity json
userId UserId
...
其中userId 是外键。
我需要创建一个端点才能创建一个新的 Activity,并且客户端需要能够指定 userId。
为此,我使用了类似的表单
postCreateActivityR :: Hadler Value
postCreateActivityR = do
activity <- runInputPost $ Activity
<$> ...
<*> ireq textField "userId"
...
这样做会出现如下错误:
Couldn't match type ‘Text’ with ‘Key User’ expected type: FormInput (HandlerT App IO) (Key User)
有解决这个问题的标准方法吗?
【问题讨论】:
-
我对yesod一无所知,但我会尝试使用来自hackage.haskell.org/package/yesod-form-1.4.15/docs/…的
optionsPersistKey之类的机会
标签: haskell yesod yesod-forms