我的配置/模型中有一个非常简单的数据
Author
name Text
我希望按名称选择作者而不是ID 我试过这个(信息来自表格):
FormSuccess book -> do
result <- runDB $ selectSource [ AuthorName ==. title book]
书是一个数据
data FormBook = FormBook {
isbn :: Text
, author :: Text
, title :: Text
, description :: Maybe Text
}
但是我收到了这个错误
Couldn't match type `[SelectOpt Author]' with `HandlerT App IO'
Expected type: YesodPersistBackend
App
(HandlerT App IO)
(Data.Conduit.Internal.Source m0 (Entity Author))
Actual type: [SelectOpt Author]
-> Data.Conduit.Internal.Source m0 (Entity Author)
In the return type of a call of `selectSource'
Probable cause: `selectSource' is applied to too few arguments
In the second argument of `($)', namely
`selectSource [AuthorName ==. (author book)]'
In a stmt of a 'do' block:
authorresult <- runDB $ selectSource [AuthorName ==. (author book)]
我在Author PersistenceEntity和PersistenceField之前尝试过,但它们不在范围内。 除了原始查询之外,我没有任何其他想法。