我是Yesod Haskell的新手,我非常喜欢它,但是我必须在一个月后离开它,因为我无法解决这个问题:我有版本 yesod-core version:1.0.1.3 我遵循了这个例子: More Client Side Yesod:todo 示例 我可以创建自己的页面并通过 json 使用数据填充它使用 json 添加新记录后但我无法删除或更改记录,因为我找不到带回密钥的方法。我不能使用这个系统来导出数据,如下所述:Parsing a JSON post and Correct way to do a "join" in persist with yesod and aeson -0.6.0.2: Fast JSON parsing and encoding因为我总是收到这个错误:
Exception when trying to run compile-time code:
Data.Aeson.TH.withType: Unsupported type: TySynD Model.Elarticoli [] (AppT (ConT Model.ElarticoliGeneric) (ConT Database.MongoDB.Query.Action))
Code: deriveFromJSON (id) ''Elarticoli
如果我使用这个系统:
Elarticoli
marca Text
descrizione Text
idum Int
prezzo Double
instance FromJSON (Key id Elarticoli) where
parseJSON = fmap Key . parseJSON
instance FromJSON Elarticoli where
parseJSON (Object v) = Elarticoli
<$> v .: "marca"
<*> v .: "descrizione"
<*> v .: "idum"
<*> v .: "prezzo"
parseJSON _ = fail "Invalid Elarticoli"
postAeldatidelR :: Handler ()
postAeldatidelR = do
id <- parseJsonBody_
runDB (delete id)
sendResponseStatus status204 ()
我总是收到这个错误:
Handler/Aeldati.hs:72:12:
Ambiguous type variable `val0' in the constraint:
(PersistEntity val0) arising from a use of `delete'
Probable fix: add a type signature that fixes these type variable(s)
In the first argument of `runDB', namely `(delete id)'
In a stmt of a 'do' block: runDB (delete id)
In the expression:
do { id <- parseJsonBody_;
runDB (delete id);
sendResponseStatus status204 () }
对于持久性,我使用 MongoDB。我必须回去用Java工作吗?谢谢你的帮助。