persistent-postgresql-2.13.7.0: Backend for the persistent library using postgresql.
Safe HaskellNone
LanguageHaskell2010

Database.Persist.Postgresql

Description

A postgresql backend for persistent.

Synopsis

Documentation

withPostgresqlPool Source #

Arguments

:: (MonadLoggerIO m, MonadUnliftIO m) 
=> ConnectionString

Connection string to the database.

-> Int

Number of connections to be kept open in the pool.

-> (Pool SqlBackend -> m a)

Action to be executed that uses the connection pool.

-> m a 

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. The provided action should use runSqlConn and *not* runReaderT because the former brackets the database action with transaction begin/commit.

withPostgresqlPoolWithVersion Source #

Arguments

:: (MonadUnliftIO m, MonadLoggerIO m) 
=> (Connection -> IO (Maybe Double))

Action to perform to get the server version.

-> ConnectionString

Connection string to the database.

-> Int

Number of connections to be kept open in the pool.

-> (Pool SqlBackend -> m a)

Action to be executed that uses the connection pool.

-> m a 

Same as withPostgresPool, but takes a callback for obtaining the server version (to work around an Amazon Redshift bug).

Since: 2.6.2

withPostgresqlPoolWithConf Source #

Arguments

:: (MonadUnliftIO m, MonadLoggerIO m) 
=> PostgresConf

Configuration for connecting to Postgres

-> PostgresConfHooks

Record of callback functions

-> (Pool SqlBackend -> m a)

Action to be executed that uses the connection pool.

-> m a 

Same as withPostgresqlPool, but can be configured with PostgresConf and PostgresConfHooks.

Since: 2.11.0.0

withPostgresqlPoolModified Source #

Arguments

:: (MonadUnliftIO m, MonadLoggerIO m) 
=> (Connection -> IO ())

Action to perform after connection is created.

-> ConnectionString

Connection string to the database.

-> Int

Number of connections to be kept open in the pool.

-> (Pool SqlBackend -> m t) 
-> m t 

Same as withPostgresqlPool, but with the createPostgresqlPoolModified feature.

Since: 2.13.5.0

withPostgresqlPoolModifiedWithVersion Source #

Arguments

:: (MonadUnliftIO m, MonadLoggerIO m) 
=> (Connection -> IO (Maybe Double))

Action to perform to get the server version.

-> (Connection -> IO ())

Action to perform after connection is created.

-> ConnectionString

Connection string to the database.

-> Int

Number of connections to be kept open in the pool.

-> (Pool SqlBackend -> m t) 
-> m t 

Same as withPostgresqlPool, but with the createPostgresqlPoolModifiedWithVersion feature.

Since: 2.13.5.0

withPostgresqlConn :: (MonadUnliftIO m, MonadLoggerIO m) => ConnectionString -> (SqlBackend -> m a) -> m a Source #

Same as withPostgresqlPool, but instead of opening a pool of connections, only one connection is opened. The provided action should use runSqlConn and *not* runReaderT because the former brackets the database action with transaction begin/commit.

withPostgresqlConnWithVersion :: (MonadUnliftIO m, MonadLoggerIO m) => (Connection -> IO (Maybe Double)) -> ConnectionString -> (SqlBackend -> m a) -> m a Source #

Same as withPostgresqlConn, but takes a callback for obtaining the server version (to work around an Amazon Redshift bug).

Since: 2.6.2

createPostgresqlPool Source #

Arguments

:: (MonadUnliftIO m, MonadLoggerIO m) 
=> ConnectionString

Connection string to the database.

-> Int

Number of connections to be kept open in the pool.

-> m (Pool SqlBackend) 

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.

createPostgresqlPoolModified Source #

Arguments

:: (MonadUnliftIO m, MonadLoggerIO m) 
=> (Connection -> IO ())

Action to perform after connection is created.

-> ConnectionString

Connection string to the database.

-> Int

Number of connections to be kept open in the pool.

-> m (Pool SqlBackend) 

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

Since: 2.1.3

createPostgresqlPoolModifiedWithVersion Source #

Arguments

:: (MonadUnliftIO m, MonadLoggerIO m) 
=> (Connection -> IO (Maybe Double))

Action to perform to get the server version.

-> (Connection -> IO ())

Action to perform after connection is created.

-> ConnectionString

Connection string to the database.

-> Int

Number of connections to be kept open in the pool.

-> m (Pool SqlBackend) 

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).

Since: 2.6.2

createPostgresqlPoolTailored Source #

Arguments

:: (MonadUnliftIO m, MonadLoggerIO m) 
=> ((Connection -> IO ()) -> (Connection -> IO (NonEmpty Word)) -> ((Connection -> SqlBackend) -> Connection -> SqlBackend) -> ConnectionString -> LogFunc -> IO SqlBackend)

Action that creates a postgresql connection (please see documentation on the un-exported open' function in this same module.

-> (Connection -> IO (Maybe Double))

Action to perform to get the server version.

-> (Connection -> IO ())

Action to perform after connection is created.

-> ConnectionString

Connection string to the database.

-> Int

Number of connections to be kept open in the pool.

-> m (Pool SqlBackend) 

Same as createPostgresqlPoolModifiedWithVersion, but takes a custom connection-creation function.

The only time you should reach for this function is if you need to write custom logic for creating a connection to the database.

Since: 2.13.6

createPostgresqlPoolWithConf Source #

Arguments

:: (MonadUnliftIO m, MonadLoggerIO m) 
=> PostgresConf

Configuration for connecting to Postgres

-> PostgresConfHooks

Record of callback functions

-> m (Pool SqlBackend) 

Same as createPostgresqlPool, but can be configured with PostgresConf and PostgresConfHooks.

Since: 2.11.0.0

type ConnectionString = ByteString Source #

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.

data HandleUpdateCollision record Source #

This type is used to determine how to update rows using Postgres' INSERT ... ON CONFLICT KEY UPDATE functionality, exposed via upsertWhere and upsertManyWhere in this library.

Since: 2.12.1.0

copyField :: PersistField typ => EntityField record typ -> HandleUpdateCollision record Source #

Copy the field directly from the record.

Since: 2.12.1.0

copyUnlessNull :: PersistField typ => EntityField record (Maybe typ) -> HandleUpdateCollision record Source #

Copy the field into the database only if the value in the corresponding record is non-NULL.

@since 2.12.1.0

copyUnlessEmpty :: (Monoid typ, PersistField typ) => EntityField record typ -> HandleUpdateCollision record Source #

Copy the field into the database only if the value in the corresponding record is non-empty, where "empty" means the Monoid definition for mempty. Useful for Text, String, ByteString, etc.

The resulting HandleUpdateCollision type is useful for the upsertManyWhere function.

@since 2.12.1.0

copyUnlessEq :: PersistField typ => EntityField record typ -> typ -> HandleUpdateCollision record Source #

Copy the field into the database only if the field is not equal to the provided value. This is useful to avoid copying weird nullary data into the database.

The resulting HandleUpdateCollision type is useful for the upsertMany function.

@since 2.12.1.0

excludeNotEqualToOriginal :: (PersistField typ, PersistEntity rec) => EntityField rec typ -> Filter rec Source #

Exclude any record field if it doesn't match the filter record. Used only in upsertWhere and upsertManyWhere

TODO: we could probably make a sum type for the Filter record that's passed into the upsertWhere and upsertManyWhere methods that has similar behavior to the HandleCollisionUpdate type.

Since: 2.12.1.0

data PostgresConf Source #

Information required to connect to a PostgreSQL database using persistent's generic facilities. These values are the same that are given to withPostgresqlPool.

Constructors

PostgresConf 

Fields

Instances

Instances details
FromJSON PostgresConf Source # 
Instance details

Defined in Database.Persist.Postgresql

Data PostgresConf Source # 
Instance details

Defined in Database.Persist.Postgresql

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> PostgresConf -> c PostgresConf Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c PostgresConf Source #

toConstr :: PostgresConf -> Constr Source #

dataTypeOf :: PostgresConf -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c PostgresConf) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PostgresConf) Source #

gmapT :: (forall b. Data b => b -> b) -> PostgresConf -> PostgresConf Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PostgresConf -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PostgresConf -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> PostgresConf -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> PostgresConf -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> PostgresConf -> m PostgresConf Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> PostgresConf -> m PostgresConf Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> PostgresConf -> m PostgresConf Source #

Read PostgresConf Source # 
Instance details

Defined in Database.Persist.Postgresql

Show PostgresConf Source # 
Instance details

Defined in Database.Persist.Postgresql

PersistConfig PostgresConf Source # 
Instance details

Defined in Database.Persist.Postgresql

type PersistConfigBackend PostgresConf Source # 
Instance details

Defined in Database.Persist.Postgresql

type PersistConfigPool PostgresConf Source # 
Instance details

Defined in Database.Persist.Postgresql

upsertWhere :: forall backend record (m :: Type -> Type). (backend ~ PersistEntityBackend record, PersistEntity record, PersistEntityBackend record ~ SqlBackend, MonadIO m, PersistStore backend, BackendCompatible SqlBackend backend, OnlyOneUniqueKey record) => record -> [Update record] -> [Filter record] -> ReaderT backend m () Source #

Postgres specific upsertWhere. This method does the following: It will insert a record if no matching unique key exists. If a unique key exists, it will update the relevant field with a user-supplied value, however, it will only do this update on a user-supplied condition. For example, here's how this method could be called like such:

upsertWhere record [recordField =. newValue] [recordField /= newValue]

Called thusly, this method will insert a new record (if none exists) OR update a recordField with a new value assuming the condition in the last block is met.

Since: 2.12.1.0

upsertManyWhere Source #

Arguments

:: forall record backend (m :: Type -> Type). (backend ~ PersistEntityBackend record, BackendCompatible SqlBackend backend, PersistEntityBackend record ~ SqlBackend, PersistEntity record, OnlyOneUniqueKey record, MonadIO m) 
=> [record]

A list of the records you want to insert, or update

-> [HandleUpdateCollision record]

A list of the fields you want to copy over.

-> [Update record]

A list of the updates to apply that aren't dependent on the record being inserted.

-> [Filter record]

A filter condition that dictates the scope of the updates

-> ReaderT backend m () 

Postgres specific upsertManyWhere.

The first argument is a list of new records to insert.

If there's unique key collisions for some or all of the proposed insertions, you can use the second argument to specify which fields, under which conditions (using HandleUpdateCollision strategies,) will be copied from each proposed, conflicting new record onto its corresponding row already present in the database. Helpers such as copyField, copyUnlessEq, copyUnlessNull and copyUnlessEmpty are exported from this module to help with this, as well as the constructors for HandleUpdateCollision. For example, you may have a patch of updates to apply, some of which are NULL to represent "no change"; you'd use copyUnlessNull for each applicable field in this case so any new values in the patch which are NULL don't accidentally overwrite existing values in the database which are non-NULL.

Further updates to the matching records already in the database can be specified in the third argument, these are arbitrary updates independent of the new records proposed for insertion. For example, you can use this to update a timestamp or a counter for all conflicting rows.

You can use the fourth argument to provide arbitrary conditions to constrain the above updates. This way, you can choose to only alter a subset of the conflicting existing rows while leaving the others alone. For example, you may want to copy fields from new records and update a timestamp only when the corresponding existing row hasn't been soft-deleted.

For example,

  upsertManyWhere
    [record]                         -- (1)
    [ copyField recordField1         -- (2)
    , copyUnlessEq recordField2      -- (3)
    , copyUnlessNull recordField3    -- (4)
    ]
    [recordField4 =. arbitraryValue] -- (5)
    [recordField4 !=. anotherValue]  -- (6)
  1. new records to insert if there's no conflicts
  2. for each conflicting existing row, replace the value of recordField1 with the one present in the conflicting new record
  3. only replace the existing value if it's different from the one present in the conflicting new record
  4. only replace the existing value if the new value is non-NULL (i.e. don't replace existing values with NULLs.)
  5. update recordField4 with an arbitrary new value
  6. only apply the above updates for conflicting rows that meet this condition

Called thusly, this method will insert a new record (if none exists) OR it will copy three fields (recordField1, recordField2, recordField3) from the record proposed from insertion onto the existing row in the database following three different HandleUpdateCollision strategies, it will also update recordField4 with an arbitrary arbitraryValue. Both sets of updates will only be applied if the row already present in the database has a recordField4 whose value is not arbitraryValue. The corresponding SQL might look like this:

  INSERT INTO table(recordField1, recordField2, recordField3, recordField4, recordField5)
  VALUES
    (newValue1, newValue2, newValue3, newValue4, newValue5)
  ON CONFLICT (recordField2, recordField3) -- let's imagine these two columns define a unique constraint
  DO UPDATE
    SET
      recordField1 = EXCLUDED.newValue1, -- EXCLUDED points to the new, conflicting, record; so we're always replacing the old value.
      recordField2 = COALESCE(NULLIF(EXCLUDED.newValue2, table.recordField2), table.recordField2), -- if the values are the same, the NULLIF returns NULL and we coalesce into setting the column to the value it already had (i.e. no change)
      recordField3 = COALESCE(NULLIF(EXCLUDED.newValue3, NULL), table.recordField3), -- if the new value is not null, it will be set; if it's null, we coalesce into not changing the existing value.
      recordField4 = arbitraryValue -- an arbitrary update independent of what's in the EXCLUDED (new) record
    WHERE
      recordField4 <> anotherValue -- only do the above updates if the value for the existing row's recordField4 is not "anotherValue"

Since: 2.12.1.0

openSimpleConnWithVersion :: (Connection -> IO (Maybe Double)) -> LogFunc -> Connection -> IO SqlBackend Source #

Generate a SqlBackend from a Connection, but takes a callback for obtaining the server version.

Since: 2.9.1

getServerVersion :: Connection -> IO (Maybe Double) Source #

Gets the PostgreSQL server version

Since: 2.13.6

getSimpleConn :: BackendCompatible SqlBackend backend => backend -> Maybe Connection Source #

Access underlying connection, returning Nothing if the SqlBackend provided isn't backed by postgresql-simple.

Since: 2.13.0

tableName :: PersistEntity record => record -> Text Source #

Get the SQL string for the table that a PersistEntity represents. Useful for raw SQL queries.

fieldName :: PersistEntity record => EntityField record typ -> Text Source #

Get the SQL string for the field that an EntityField represents. Useful for raw SQL queries.

mockMigration :: Migration -> IO () Source #

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.

data PostgresConfHooks Source #

Hooks for configuring the Persistent/its connection to Postgres

Since: 2.11.0

Constructors

PostgresConfHooks 

Fields

  • pgConfHooksGetServerVersion :: Connection -> IO (NonEmpty Word)

    Function to get the version of Postgres

    The default implementation queries the server with "show server_version". Some variants of Postgres, such as Redshift, don't support showing the version. It's recommended you return a hardcoded version in those cases.

    Since: 2.11.0

  • pgConfHooksAfterCreate :: Connection -> IO ()

    Action to perform after a connection is created.

    Typical uses of this are modifying the connection (e.g. to set the schema) or logging a connection being created.

    The default implementation does nothing.

    Since: 2.11.0

defaultPostgresConfHooks :: PostgresConfHooks Source #

Default settings for PostgresConfHooks. See the individual fields of PostgresConfHooks for the default values.

Since: 2.11.0

data RawPostgresql backend Source #

Wrapper for persistent SqlBackends that carry the corresponding Connection.

Since: 2.13.1.0

Constructors

RawPostgresql 

Fields

Instances

Instances details
BackendCompatible b (RawPostgresql b) Source # 
Instance details

Defined in Database.Persist.Postgresql

(PersistCore b, PersistCore (RawPostgresql b), FromJSON (BackendKey b)) => FromJSON (BackendKey (RawPostgresql b)) Source # 
Instance details

Defined in Database.Persist.Postgresql

(PersistCore b, PersistCore (RawPostgresql b), ToJSON (BackendKey b)) => ToJSON (BackendKey (RawPostgresql b)) Source # 
Instance details

Defined in Database.Persist.Postgresql

(PersistCore b, PersistCore (RawPostgresql b), Bounded (BackendKey b)) => Bounded (BackendKey (RawPostgresql b)) Source # 
Instance details

Defined in Database.Persist.Postgresql

(PersistCore b, PersistCore (RawPostgresql b), Enum (BackendKey b)) => Enum (BackendKey (RawPostgresql b)) Source # 
Instance details

Defined in Database.Persist.Postgresql

(PersistCore b, PersistCore (RawPostgresql b), Num (BackendKey b)) => Num (BackendKey (RawPostgresql b)) Source # 
Instance details

Defined in Database.Persist.Postgresql

(PersistCore b, PersistCore (RawPostgresql b), Read (BackendKey b)) => Read (BackendKey (RawPostgresql b)) Source # 
Instance details

Defined in Database.Persist.Postgresql

(PersistCore b, PersistCore (RawPostgresql b), Integral (BackendKey b)) => Integral (BackendKey (RawPostgresql b)) Source # 
Instance details

Defined in Database.Persist.Postgresql

(PersistCore b, PersistCore (RawPostgresql b), Real (BackendKey b)) => Real (BackendKey (RawPostgresql b)) Source # 
Instance details

Defined in Database.Persist.Postgresql

(PersistCore b, PersistCore (RawPostgresql b), Show (BackendKey b)) => Show (BackendKey (RawPostgresql b)) Source # 
Instance details

Defined in Database.Persist.Postgresql

(PersistCore b, PersistCore (RawPostgresql b), Eq (BackendKey b)) => Eq (BackendKey (RawPostgresql b)) Source # 
Instance details

Defined in Database.Persist.Postgresql

(PersistCore b, PersistCore (RawPostgresql b), Ord (BackendKey b)) => Ord (BackendKey (RawPostgresql b)) Source # 
Instance details

Defined in Database.Persist.Postgresql

(PersistCore b, PersistCore (RawPostgresql b), PersistField (BackendKey b)) => PersistField (BackendKey (RawPostgresql b)) Source # 
Instance details

Defined in Database.Persist.Postgresql

(HasPersistBackend b, PersistQueryRead b) => PersistQueryRead (RawPostgresql b) Source # 
Instance details

Defined in Database.Persist.Postgresql

Methods

selectSourceRes :: forall record (m1 :: Type -> Type) (m2 :: Type -> Type). (PersistRecordBackend record (RawPostgresql b), MonadIO m1, MonadIO m2) => [Filter record] -> [SelectOpt record] -> ReaderT (RawPostgresql b) m1 (Acquire (ConduitM () (Entity record) m2 ())) Source #

selectFirst :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record (RawPostgresql b)) => [Filter record] -> [SelectOpt record] -> ReaderT (RawPostgresql b) m (Maybe (Entity record)) Source #

selectKeysRes :: forall (m1 :: Type -> Type) (m2 :: Type -> Type) record. (MonadIO m1, MonadIO m2, PersistRecordBackend record (RawPostgresql b)) => [Filter record] -> [SelectOpt record] -> ReaderT (RawPostgresql b) m1 (Acquire (ConduitM () (Key record) m2 ())) Source #

count :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record (RawPostgresql b)) => [Filter record] -> ReaderT (RawPostgresql b) m Int Source #

exists :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record (RawPostgresql b)) => [Filter record] -> ReaderT (RawPostgresql b) m Bool Source #

(HasPersistBackend b, PersistQueryWrite b) => PersistQueryWrite (RawPostgresql b) Source # 
Instance details

Defined in Database.Persist.Postgresql

Methods

updateWhere :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record (RawPostgresql b)) => [Filter record] -> [Update record] -> ReaderT (RawPostgresql b) m () Source #

deleteWhere :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record (RawPostgresql b)) => [Filter record] -> ReaderT (RawPostgresql b) m () Source #

HasPersistBackend b => HasPersistBackend (RawPostgresql b) Source # 
Instance details

Defined in Database.Persist.Postgresql

Associated Types

type BaseBackend (RawPostgresql b0) 
Instance details

Defined in Database.Persist.Postgresql

PersistCore b => PersistCore (RawPostgresql b) Source # 
Instance details

Defined in Database.Persist.Postgresql

(HasPersistBackend b, PersistStoreRead b) => PersistStoreRead (RawPostgresql b) Source # 
Instance details

Defined in Database.Persist.Postgresql

Methods

get :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawPostgresql b)) => Key record -> ReaderT (RawPostgresql b) m (Maybe record) Source #

getMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawPostgresql b)) => [Key record] -> ReaderT (RawPostgresql b) m (Map (Key record) record) Source #

(HasPersistBackend b, PersistStoreWrite b) => PersistStoreWrite (RawPostgresql b) Source # 
Instance details

Defined in Database.Persist.Postgresql

Methods

insert :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawPostgresql b), SafeToInsert record) => record -> ReaderT (RawPostgresql b) m (Key record) Source #

insert_ :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawPostgresql b), SafeToInsert record) => record -> ReaderT (RawPostgresql b) m () Source #

insertMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawPostgresql b), SafeToInsert record) => [record] -> ReaderT (RawPostgresql b) m [Key record] Source #

insertMany_ :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawPostgresql b), SafeToInsert record) => [record] -> ReaderT (RawPostgresql b) m () Source #

insertEntityMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawPostgresql b)) => [Entity record] -> ReaderT (RawPostgresql b) m () Source #

insertKey :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawPostgresql b)) => Key record -> record -> ReaderT (RawPostgresql b) m () Source #

repsert :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawPostgresql b)) => Key record -> record -> ReaderT (RawPostgresql b) m () Source #

repsertMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawPostgresql b)) => [(Key record, record)] -> ReaderT (RawPostgresql b) m () Source #

replace :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawPostgresql b)) => Key record -> record -> ReaderT (RawPostgresql b) m () Source #

delete :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawPostgresql b)) => Key record -> ReaderT (RawPostgresql b) m () Source #

update :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawPostgresql b)) => Key record -> [Update record] -> ReaderT (RawPostgresql b) m () Source #

updateGet :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawPostgresql b)) => Key record -> [Update record] -> ReaderT (RawPostgresql b) m record Source #

(HasPersistBackend b, PersistUniqueRead b) => PersistUniqueRead (RawPostgresql b) Source # 
Instance details

Defined in Database.Persist.Postgresql

Methods

getBy :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawPostgresql b)) => Unique record -> ReaderT (RawPostgresql b) m (Maybe (Entity record)) Source #

existsBy :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawPostgresql b)) => Unique record -> ReaderT (RawPostgresql b) m Bool Source #

(HasPersistBackend b, PersistUniqueWrite b) => PersistUniqueWrite (RawPostgresql b) Source # 
Instance details

Defined in Database.Persist.Postgresql

Methods

deleteBy :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawPostgresql b)) => Unique record -> ReaderT (RawPostgresql b) m () Source #

insertUnique :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawPostgresql b), SafeToInsert record) => record -> ReaderT (RawPostgresql b) m (Maybe (Key record)) Source #

insertUnique_ :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawPostgresql b), SafeToInsert record) => record -> ReaderT (RawPostgresql b) m (Maybe ()) Source #

upsert :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawPostgresql b), OnlyOneUniqueKey record, SafeToInsert record) => record -> [Update record] -> ReaderT (RawPostgresql b) m (Entity record) Source #

upsertBy :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawPostgresql b), SafeToInsert record) => Unique record -> record -> [Update record] -> ReaderT (RawPostgresql b) m (Entity record) Source #

putMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record (RawPostgresql b), SafeToInsert record) => [record] -> ReaderT (RawPostgresql b) m () Source #

(PersistCore b, PersistCore (RawPostgresql b), PersistFieldSql (BackendKey b)) => PersistFieldSql (BackendKey (RawPostgresql b)) Source # 
Instance details

Defined in Database.Persist.Postgresql

BackendCompatible (RawPostgresql b) (RawPostgresql b) Source # 
Instance details

Defined in Database.Persist.Postgresql

newtype BackendKey (RawPostgresql b) Source # 
Instance details

Defined in Database.Persist.Postgresql

type BaseBackend (RawPostgresql b0) Source # 
Instance details

Defined in Database.Persist.Postgresql

createRawPostgresqlPool Source #

Arguments

:: (MonadUnliftIO m, MonadLoggerIO m) 
=> ConnectionString

Connection string to the database.

-> Int

Number of connections to be kept open in the pool.

-> m (Pool (RawPostgresql SqlBackend)) 

Create a PostgreSQL connection pool which also exposes the raw connection. The raw counterpart to createPostgresqlPool.

Since: 2.13.1.0

createRawPostgresqlPoolModified Source #

Arguments

:: (MonadUnliftIO m, MonadLoggerIO m) 
=> (Connection -> IO ())

Action to perform after connection is created.

-> ConnectionString

Connection string to the database.

-> Int

Number of connections to be kept open in the pool.

-> m (Pool (RawPostgresql SqlBackend)) 

The raw counterpart to createPostgresqlPoolModified.

Since: 2.13.1.0

createRawPostgresqlPoolModifiedWithVersion Source #

Arguments

:: (MonadUnliftIO m, MonadLoggerIO m) 
=> (Connection -> IO (Maybe Double))

Action to perform to get the server version.

-> (Connection -> IO ())

Action to perform after connection is created.

-> ConnectionString

Connection string to the database.

-> Int

Number of connections to be kept open in the pool.

-> m (Pool (RawPostgresql SqlBackend)) 

The raw counterpart to createPostgresqlPoolModifiedWithVersion.

Since: 2.13.1.0

createRawPostgresqlPoolWithConf Source #

Arguments

:: (MonadUnliftIO m, MonadLoggerIO m) 
=> PostgresConf

Configuration for connecting to Postgres

-> PostgresConfHooks

Record of callback functions

-> m (Pool (RawPostgresql SqlBackend)) 

The raw counterpart to createPostgresqlPoolWithConf.

Since: 2.13.1.0

createBackend :: LogFunc -> NonEmpty Word -> IORef (Map Text Statement) -> Connection -> SqlBackend Source #

Create the backend given a logging function, server version, mutable statement cell, and connection.

Since: 2.13.6