Stability | experimental |
---|---|
Maintainer | Alp Mestanogullari <alp@zalora.com> |
Safe Haskell | None |
An helpful wrapper around Int64
that you can tie to
the standard response types in Servant.Response.Prelude with
the instances defined in this module.
- data PGResult o
- class ToPGResult r where
- toPGResult :: ToPGResult r => IO r -> IO (PGResult o)
- pgresultOfInts :: IO [Only Int] -> IO (PGResult o)
- pgresultOfInt64 :: IO Int64 -> IO (PGResult o)
- module Servant.Context.PostgreSQL
Documentation
A wrapper around Int64
, which is what
PG hands us back when running
execute
.
The o
type parameter lets us tag
the result with the operation that
we're running. This lets us turn
results into a proper response
(response body + status) differently
for Add
and Update
for example.
Eq (PGResult o) | |
Num (PGResult o) | |
Ord (PGResult o) | |
Show (PGResult o) | |
Response (UpdateResponse Add) (PGResult Add) | If the |
Response (UpdateResponse Delete) (PGResult Delete) | If the |
Response (UpdateResponse Update) (PGResult Update) | If the |
class ToPGResult r whereSource
Class of types that can be converted to a
PGResult
.
toPGResult :: ToPGResult r => IO r -> IO (PGResult o)Source
Run a database action and convert its
result to a PGResult
.
This will only typecheck on queries that
return Int64
or [
, or a custom
type of yours for which you provide a Only
Int
]ToPGResult
instance.
module Servant.Context.PostgreSQL