2
저는 persistent 및 persistent-mysql을 사용하고 있습니다. 나는영구 : 텍스트를 키로 변환
entity <- selectFirst [SomeField ==. someId]
를 사용하여 내 기능
testFun :: T.Text -> SqlM()
testFun someId = ...
나는 데이터베이스를 조회 할 수 있습니다 내부 모나드 SqlM
type SqlM a = SqlPersist (ResourceT IO) a)
을하지만 ID로 entitys을 선택하고 싶습니다. 나는 someId를 Key - Type으로 변환/팩해야합니다. 나는이 그것을 할 수있는 방법이 아니라는 것을 알고,하지만 난 시도 : 잘못된 무슨
Couldn't match type `PersistEntityBackend
(Entity (DBTableGeneric backend0))'
with `Database.Persist.GenericSql.Raw.SqlBackend'
The type variable `backend0' is ambiguous
Possible fix: add a type signature that fixes these type variable(s)
Expected type: Key (Entity (DBTableGeneric backend0))
Actual type: KeyBackend
Database.Persist.GenericSql.Raw.SqlBackend
(Entity (DBTableGeneric backend0))
In the second argument of `($)', namely
`Key {unKey = PersistInt64 (read $ T.unpack someId)}'
어떤 아이디어 :
entity <- get $ Key { unKey = PersistInt64 (read $ T.unpack someId) }
이 실패?
형식 서명을 추가해야하는 대상은 무엇입니까? _KeyBackend SqlBackend entity_ 키를 추가하려고했지만 여전히 위의 오류가 나타납니다. – agrafix
'(fromPathPiece someId :: 아마도 DBTableId)'와 같은 것을 시도해보십시오. –
빠른 도움을 주셔서 대단히 감사합니다. – agrafix