【发布时间】:2017-01-09 20:17:37
【问题描述】:
拥有以下数据库模型,我正在尝试获取事件的城市名称(来自城市的某个字段 - 相关实体):
City json
name Text
countryId CountryId
UniqueCity name
deriving Eq
deriving Show
Event
title Text
description Text
date UTCTime
cityId CityId
extractCityName :: EventId -> Text
extractCityName eventId = do
event <- runDB $ get404 eventId
city <- runDB $ get404 (eventCityId event)
x <- cityName city
return cityName
即使尚未调用该函数(在编译时),我也会遇到此错误:
Couldn't match expected type `HandlerT site0 IO t0' with actual type `Text'
In a stmt of a 'do' block: x <- cityName city
In the expression:
do { event <- runDB $ get404 eventId;
city <- runDB $ get404 (eventCityId event);
x <- cityName city;
return cityName }
你能帮我弄清楚我的代码有什么问题吗?
【问题讨论】: