我有以下内容:
asSqlBackendReader :: ReaderT SqlBackend m a -> ReaderT SqlBackend m a
asSqlBackendReader = id
insertEnt :: (Entity a) -> IO (Key (Entity a))
insertEnt x = runWithDb $ do
insert $ x
where runWithDb = runSqlite "test.db" . asSqlBackendReader
的目的asSqlBAckendReader
是由于Persistent selectList 导致错误 "Couldn't match type 'BaseBackend backend0' with 'SqlBackend'"。
我遇到了以下错误:
• Couldn't match type ‘PersistEntityBackend (Entity a)’
with ‘SqlBackend’
arising from a use of ‘insert’
• In a stmt of a 'do' block: insert $ x
In the second argument of ‘($)’, namely ‘do { insert $ x }’
In the expression: runWithDb $ do { insert $ x }