use*_*258 1 haskell persistent yesod
在Persistent中,如何将XyzId(PersonId,whateverid)转换为其表示的整数?
您可以使用unKey获得PersistValue从IDENT,并通过模式匹配从它那里得到整数:
intKey :: PersistEntity val => Key val -> Int64
intKey key = case unKey key of
PersistInt64 int64 -> int64
_ -> error "BUG: Unexpected ident"
Run Code Online (Sandbox Code Playgroud)