-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Make queries against Postgresql. -- -- Please see the README at -- https://github.com/NoRedInk/haskell-libraries/tree/trunk/nri-postgresql#readme. @package nri-postgresql @version 0.1.0.1 -- | Functions for running Postgres queries. module Postgres -- | A connection to Postgres. You need this for making Postgres queries. data Connection -- | Create a Connection. connection :: Settings -> Acquire Connection -- | Postgres connection details. You can use decoder to create one -- of these. data Settings -- | Create a Settings value by reading settings from environment -- values. -- --
-- [sql| SELECT name, breed FROM doggos |] --sql :: QuasiQuoter -- | Run a query against MySql. This will return a list of rows, where the -- row type is a tuple containing the queried columns. -- --
-- doQuery -- connection -- [sql| SELECT name, breed FROM doggos |] -- (\result -> -- case result of -- Ok rows -> Task.succeed rows -- Err err -> Task.fail err -- ) --doQuery :: HasCallStack => Connection -> Query row -> (Result Error [row] -> Task e a) -> Task e a -- | Perform a database transaction. transaction :: Connection -> (Connection -> Task e a) -> Task e a -- | Run code in a transaction, then roll that transaction back. Useful in -- tests that shouldn't leave anything behind in the DB. inTestTransaction :: Connection -> (Connection -> Task x a) -> Task x a -- | A PGColumn t a instance describes how te decode a PostgreSQL -- type t to a. class PGType t => PGColumn (t :: Symbol) a -- | Decode the PostgreSQL text representation into a value. pgDecode :: PGColumn t a => PGTypeID t -> PGTextValue -> a -- | A PGParameter t a instance describes how to encode a -- PostgreSQL type t from a. class PGType t => PGParameter (t :: Symbol) a -- | Encode a value to a PostgreSQL text representation. pgEncode :: PGParameter t a => PGTypeID t -> a -> PGTextValue instance Database.PostgreSQL.Typed.Types.PGType "jsonb" => Database.PostgreSQL.Typed.Types.PGType "jsonb[]" instance Database.PostgreSQL.Typed.Types.PGType "jsonb" => Database.PostgreSQL.Typed.Array.PGArrayType "jsonb[]" -- | Write tests that require a Postgres connection. module Postgres.Test -- | A variant of test that is passed a Postgres connection, for -- doing tests that require access to Postgres. The test body is run -- within a transaction that gets rolled back after the test completes. -- -- Usage: -- -- Postgres.Test.test "My Postgres test" Postgres - do -- test -- stuff! test :: HasCallStack => Text -> (Connection -> Expectation) -> Test