Add valkey helper (fixes #9).

This commit is contained in:
Felipe Lessa 2012-12-14 16:45:59 -02:00
parent e5e5476683
commit aa2c207dd1

View File

@ -50,6 +50,9 @@ module Database.Esqueleto
, delete
, update
-- * Helpers
, valkey
-- * Re-exports
-- $reexports
, deleteKey
@ -57,6 +60,7 @@ module Database.Esqueleto
, module Database.Persist.Store
) where
import Data.Int (Int64)
import Database.Esqueleto.Internal.Language
import Database.Esqueleto.Internal.Sql
import Database.Persist.Store hiding (delete)
@ -294,6 +298,16 @@ import qualified Database.Persist.Store
----------------------------------------------------------------------
-- | @valkey i = val (Key (PersistInt64 i))@
-- (<https://github.com/meteficha/esqueleto/issues/9>).
valkey :: Esqueleto query expr backend =>
Int64 -> expr (Value (Key entity))
valkey = val . Key . PersistInt64
----------------------------------------------------------------------
-- | Synonym for 'Database.Persist.Store.delete' that does not
-- clash with @esqueleto@'s 'delete'.
deleteKey :: ( PersistStore m