-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Useful functions and instances for using servant with a PostgreSQL context -- -- Useful functions and instances for using servant with a PostgreSQL -- context @package servant-postgresql @version 0.1 -- | Useful functions and instances for using servant with a PostgreSQL -- database. -- -- module Servant.Context.PostgreSQL -- | Create a Context Connection from the given -- ConnectInfo. -- -- This means a new connection will be fired whenever you perform a -- database operation. If you want to avoid that, see the -- pooledContextOfXXX functions. contextOfConnInfo :: ConnectInfo -> Context Connection -- | Create a Context Connection from the given -- connection string. -- -- This means a new connection will be fired whenever you perform a -- database operation. If you want to avoid that, see the -- pooledContextOfXXX functions. contextOfConnStr :: ByteString -> Context Connection -- | Create a Context that'll use a Pool of PostgreSQL -- Connections internally, from a ConnectInfo value. pooledContextOfConnInfo :: Int -> NominalDiffTime -> Int -> ConnectInfo -> IO (Context Connection) -- | Create a Context that'll use a Pool of PostgreSQL -- Connections internally, from a connection string (a -- ByteString). pooledContextOfConnStr :: Int -> NominalDiffTime -> Int -> ByteString -> IO (Context Connection) -- | 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. module Servant.PostgreSQL.Prelude -- | 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. data PGResult o -- | Class of types that can be converted to a PGResult. -- -- This package provides instances for Int64 and [Only -- Int] class ToPGResult r fromRes :: ToPGResult r => r -> PGResult o -- | Run a database action and convert its result to a PGResult. -- -- This will only typecheck on queries that return Int64 or -- [Only Int], or a custom type of yours for which -- you provide a ToPGResult instance. toPGResult :: ToPGResult r => IO r -> IO (PGResult o) -- | Run an IO action that returns [Only Int] -- and convert the result to a PGResult. pgresultOfInts :: IO [Only Int] -> IO (PGResult o) -- | Run an IO action that returns Int64 and convert the -- result to a PGResult. pgresultOfInt64 :: IO Int64 -> IO (PGResult o) instance Eq (PGResult o) instance Ord (PGResult o) instance Num (PGResult o) instance Show (PGResult o) instance Response (UpdateResponse Update) (PGResult Update) instance Response (UpdateResponse Delete) (PGResult Delete) instance Response (UpdateResponse Add) (PGResult Add) instance ToPGResult [Only Int] instance ToPGResult Int64