-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Backend for the persistent library using postgresql. -- -- Based on the postgresql-simple package @package persistent-postgresql @version 2.9.0 -- | A postgresql backend for persistent. module Database.Persist.Postgresql -- | Create a PostgreSQL connection pool and run the given action. The pool -- is properly released after the action finishes using it. Note that you -- should not use the given ConnectionPool outside the action -- since it may already have been released. withPostgresqlPool :: (MonadLogger m, MonadUnliftIO m, IsSqlBackend backend) => ConnectionString -> Int -> (Pool backend -> m a) -> m a -- | Same as withPostgresPool, but takes a callback for obtaining -- the server version (to work around an Amazon Redshift bug). withPostgresqlPoolWithVersion :: (MonadUnliftIO m, MonadLogger m, IsSqlBackend backend) => (Connection -> IO (Maybe Double)) -> ConnectionString -> Int -> (Pool backend -> m a) -> m a -- | Same as withPostgresqlPool, but instead of opening a pool of -- connections, only one connection is opened. withPostgresqlConn :: (MonadUnliftIO m, MonadLogger m, IsSqlBackend backend) => ConnectionString -> (backend -> m a) -> m a -- | Same as withPostgresqlConn, but takes a callback for obtaining -- the server version (to work around an Amazon Redshift bug). withPostgresqlConnWithVersion :: (MonadUnliftIO m, MonadLogger m, IsSqlBackend backend) => (Connection -> IO (Maybe Double)) -> ConnectionString -> (backend -> m a) -> m a -- | Create a PostgreSQL connection pool. Note that it's your -- responsibility to properly close the connection pool when unneeded. -- Use withPostgresqlPool for an automatic resource control. createPostgresqlPool :: (MonadUnliftIO m, MonadLogger m, IsSqlBackend backend) => ConnectionString -> Int -> m (Pool backend) -- | Same as createPostgresqlPool, but additionally takes a callback -- function for some connection-specific tweaking to be performed after -- connection creation. This could be used, for example, to change the -- schema. For more information, see: -- -- -- https://groups.google.com/d/msg/yesodweb/qUXrEN_swEo/O0pFwqwQIdcJ createPostgresqlPoolModified :: (MonadUnliftIO m, MonadLogger m, IsSqlBackend backend) => (Connection -> IO ()) -> ConnectionString -> Int -> m (Pool backend) -- | Same as other similarly-named functions in this module, but takes -- callbacks for obtaining the server version (to work around an Amazon -- Redshift bug) and connection-specific tweaking (to change the schema). createPostgresqlPoolModifiedWithVersion :: (MonadUnliftIO m, MonadLogger m, IsSqlBackend backend) => (Connection -> IO (Maybe Double)) -> (Connection -> IO ()) -> ConnectionString -> Int -> m (Pool backend) -- | A libpq connection string. A simple example of connection -- string would be "host=localhost port=5432 user=test dbname=test -- password=test". Please read libpq's documentation at -- https://www.postgresql.org/docs/current/static/libpq-connect.html -- for more details on how to create such strings. type ConnectionString = ByteString -- | Information required to connect to a PostgreSQL database using -- persistent's generic facilities. These values are the same -- that are given to withPostgresqlPool. data PostgresConf PostgresConf :: ConnectionString -> Int -> PostgresConf -- | The connection string. [pgConnStr] :: PostgresConf -> ConnectionString -- | How many connections should be held in the connection pool. [pgPoolSize] :: PostgresConf -> Int -- | Generate a SqlBackend from a Connection. openSimpleConn :: (IsSqlBackend backend) => LogFunc -> Connection -> IO backend -- | Get the SQL string for the table that a PeristEntity represents. -- Useful for raw SQL queries. tableName :: (PersistEntity record) => record -> Text -- | Get the SQL string for the field that an EntityField represents. -- Useful for raw SQL queries. fieldName :: (PersistEntity record) => EntityField record typ -> Text -- | Mock a migration even when the database is not present. This function -- performs the same functionality of printMigration with the -- difference that an actual database is not needed. mockMigration :: Migration -> IO () -- | Enable a Postgres extension. See -- https://www.postgresql.org/docs/current/static/contrib.html for -- a list. migrateEnableExtension :: Text -> Migration instance Data.Data.Data Database.Persist.Postgresql.PostgresConf instance GHC.Read.Read Database.Persist.Postgresql.PostgresConf instance GHC.Show.Show Database.Persist.Postgresql.PostgresConf instance GHC.Classes.Ord Database.Persist.Postgresql.Unknown instance GHC.Read.Read Database.Persist.Postgresql.Unknown instance GHC.Show.Show Database.Persist.Postgresql.Unknown instance GHC.Classes.Eq Database.Persist.Postgresql.Unknown instance Data.Aeson.Types.FromJSON.FromJSON Database.Persist.Postgresql.PostgresConf instance Database.Persist.Class.PersistConfig.PersistConfig Database.Persist.Postgresql.PostgresConf instance Database.PostgreSQL.Simple.ToField.ToField Database.Persist.Postgresql.P instance Database.PostgreSQL.Simple.FromField.FromField Database.Persist.Postgresql.Unknown instance Database.PostgreSQL.Simple.ToField.ToField Database.Persist.Postgresql.Unknown instance GHC.Show.Show Database.Persist.Postgresql.PostgresServerVersionError instance GHC.Exception.Exception Database.Persist.Postgresql.PostgresServerVersionError -- | Filter operators for JSON values added to PostgreSQL 9.4 module Database.Persist.Postgresql.JSON -- | This operator checks inclusion of the JSON value on the right hand -- side in the JSON value on the left hand side. -- --

Objects

-- -- An empty Object matches any object -- --
--   {}                @> {} == True
--   {"a":1,"b":false} @> {} == True
--   
-- -- Any key-value will be matched top-level -- --
--   {"a":1,"b":{"c":true"}} @> {"a":1}         == True
--   {"a":1,"b":{"c":true"}} @> {"b":1}         == False
--   {"a":1,"b":{"c":true"}} @> {"b":{}}        == True
--   {"a":1,"b":{"c":true"}} @> {"c":true}      == False
--   {"a":1,"b":{"c":true"}} @> {"b":{c":true}} == True
--   
-- --

Arrays

-- -- An empty Array matches any array -- --
--   []                    @> [] == True
--   [1,2,"hi",false,null] @> [] == True
--   
-- -- Any array has to be a sub-set. Any object or array will also be -- compared as being a subset of. -- --
--   [1,2,"hi",false,null] @> [1]                       == True
--   [1,2,"hi",false,null] @> [null,"hi"]               == True
--   [1,2,"hi",false,null] @> ["hi",true]               == False
--   [1,2,"hi",false,null] @> ["hi",2,null,false,1]     == True
--   [1,2,"hi",false,null] @> [1,2,"hi",false,null,{}]  == False
--   
-- -- Arrays and objects inside arrays match the same way they'd be matched -- as being on their own. -- --
--   [1,"hi",[false,3],{"a":[null]}] @> [{}]            == True
--   [1,"hi",[false,3],{"a":[null]}] @> [{"a":[]}]      == True
--   [1,"hi",[false,3],{"a":[null]}] @> [{"b":[null]}]  == False
--   [1,"hi",[false,3],{"a":[null]}] @> [[]]            == True
--   [1,"hi",[false,3],{"a":[null]}] @> [[3]]           == True
--   [1,"hi",[false,3],{"a":[null]}] @> [[true,3]]      == False
--   
-- -- A regular value has to be a member -- --
--   [1,2,"hi",false,null] @> 1      == True
--   [1,2,"hi",false,null] @> 5      == False
--   [1,2,"hi",false,null] @> "hi"   == True
--   [1,2,"hi",false,null] @> false  == True
--   [1,2,"hi",false,null] @> "2"    == False
--   
-- -- An object will never match with an array -- --
--   [1,2,"hi",[false,3],{"a":null}] @> {}          == False
--   [1,2,"hi",[false,3],{"a":null}] @> {"a":null}  == False
--   
-- --

Other values

-- -- For any other JSON values the `(@>.)` operator functions like an -- equivalence operator. -- --
--   "hello" @> "hello"     == True
--   "hello" @> "Hello"     == False
--   "hello" @> "h"         == False
--   "hello" @> {"hello":1} == False
--   "hello" @> ["hello"]   == False
--   
--   5       @> 5       == True
--   5       @> 5.00    == True
--   5       @> 1       == False
--   5       @> 7       == False
--   12345   @> 1234    == False
--   12345   @> 2345    == False
--   12345   @> "12345" == False
--   12345   @> [1,2,3,4,5] == False
--   
--   true    @> true    == True
--   true    @> false   == False
--   false   @> true    == False
--   true    @> "true"  == False
--   
--   null    @> null    == True
--   null    @> 23      == False
--   null    @> "null"  == False
--   null    @> {}      == False
--   
(@>.) :: EntityField record Value -> Value -> Filter record infix 4 @>. -- | Same as @>. except the inclusion check is reversed. i.e. is -- the JSON value on the left hand side included in the JSON value of the -- right hand side. (<@.) :: EntityField record Value -> Value -> Filter record infix 4 <@. -- | A JSON value represented as a Haskell value. data Value instance Database.Persist.Class.PersistField.PersistField Data.Aeson.Types.Internal.Value instance Database.Persist.Sql.Class.PersistFieldSql Data.Aeson.Types.Internal.Value