我正在使用 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)
有没有解决这个问题的标准方法?