persistent-2.14.6.3: Type-safe, multi-backend data serialization.

Safe Haskell | None
Language | Haskell2010

Database.Persist.Sql.Types.Internal

Description

Breaking changes to this module are not reflected in the major version number. Prefer to import from Database.Persist.Sql instead. If you neeed something from this module, please file an issue on GitHub.

Synopsis

- class HasPersistBackend backend where
  - type BaseBackend backend
  - persistBackend :: backend -> BaseBackend backend
- class HasPersistBackend backend => IsPersistBackend backend where
  - mkPersistBackend :: BaseBackend backend -> backend
- newtype SqlReadBackend = SqlReadBackend {
  - unSqlReadBackend :: SqlBackend
  }
- newtype SqlWriteBackend = SqlWriteBackend {
  - unSqlWriteBackend :: SqlBackend
  }
- readToUnknown :: forall (m :: Type -> Type) a. Monad m => ReaderT SqlReadBackend m a -> ReaderT SqlBackend m a
- readToWrite :: forall (m :: Type -> Type) a. Monad m => ReaderT SqlReadBackend m a -> ReaderT SqlWriteBackend m a
- writeToUnknown :: forall (m :: Type -> Type) a. Monad m => ReaderT SqlWriteBackend m a -> ReaderT SqlBackend m a
- type LogFunc = Loc -> LogSource -> LogLevel -> LogStr -> IO ()
- data InsertSqlResult
  - = ISRSingle Text
  - | ISRInsertGet Text Text
  - | ISRManyKeys Text [PersistValue]
- data Statement = Statement {
  - stmtFinalize :: IO ()
  - stmtReset :: IO ()
  - stmtExecute :: [PersistValue] -> IO Int64
  - stmtQuery :: forall (m :: Type -> Type). MonadIO m => [PersistValue] -> Acquire (ConduitM () [PersistValue] m ())
  }
- data IsolationLevel
  - = ReadUncommitted
  - | ReadCommitted
  - | RepeatableRead
  - | Serializable
- makeIsolationLevelStatement :: (Monoid s, IsString s) => IsolationLevel -> s
- data SqlBackend = SqlBackend {
  - connPrepare :: Text -> IO Statement
  - connInsertSql :: EntityDef -> [PersistValue] -> InsertSqlResult
  - connInsertManySql :: Maybe (EntityDef -> [[PersistValue]] -> InsertSqlResult)
  - connUpsertSql :: Maybe (EntityDef -> NonEmpty (FieldNameHS, FieldNameDB) -> Text -> Text)
  - connPutManySql :: Maybe (EntityDef -> Int -> Text)
  - connStmtMap :: StatementCache
  - connClose :: IO ()
  - connMigrateSql :: [EntityDef] -> (Text -> IO Statement) -> EntityDef -> IO (Either [Text] [(Bool, Text)])
  - connBegin :: (Text -> IO Statement) -> Maybe IsolationLevel -> IO ()
  - connCommit :: (Text -> IO Statement) -> IO ()
  - connRollback :: (Text -> IO Statement) -> IO ()
  - connEscapeFieldName :: FieldNameDB -> Text
  - connEscapeTableName :: EntityDef -> Text
  - connEscapeRawName :: Text -> Text
  - connNoLimit :: Text
  - connRDBMS :: Text
  - connLimitOffset :: (Int, Int) -> Text -> Text
  - connLogFunc :: LogFunc
  - connMaxParams :: Maybe Int
  - connRepsertManySql :: Maybe (EntityDef -> Int -> Text)
  - connVault :: Vault
  - connHooks :: SqlBackendHooks
  }
- type SqlBackendCanRead backend = (BackendCompatible SqlBackend backend, PersistQueryRead backend, PersistStoreRead backend, PersistUniqueRead backend)
- type SqlBackendCanWrite backend = (SqlBackendCanRead backend, PersistQueryWrite backend, PersistStoreWrite backend, PersistUniqueWrite backend)
- type SqlReadT (m :: Type -> Type) a = forall backend. SqlBackendCanRead backend => ReaderT backend m a
- type SqlWriteT (m :: Type -> Type) a = forall backend. SqlBackendCanWrite backend => ReaderT backend m a
- type IsSqlBackend backend = (IsPersistBackend backend, BaseBackend backend ~ SqlBackend)
- newtype SqlBackendHooks = SqlBackendHooks {
  - hookGetStatement :: SqlBackend -> Text -> Statement -> IO Statement
  }

# Documentation

class HasPersistBackend backend where #

Class which allows the plucking of a `BaseBackend backend` from some larger type. For example, `instance HasPersistBackend (SqlReadBackend, Int) where type BaseBackend (SqlReadBackend, Int) = SqlBackend persistBackend = unSqlReadBackend . fst`

Associated Types

type BaseBackend backend #

Methods

persistBackend :: backend -> BaseBackend backend #

#### Instances

Instances details

HasPersistBackend SqlReadBackend # |

Instance details

Defined in Database.Persist.Sql.Types.Internal

Associated Types

type BaseBackend SqlReadBackend |
Instance details Defined in Database.Persist.Sql.Types.Internal type BaseBackend SqlReadBackend = SqlBackend

Methods

persistBackend :: SqlReadBackend -> BaseBackend SqlReadBackend #

HasPersistBackend SqlWriteBackend # |

Instance details

Defined in Database.Persist.Sql.Types.Internal

Associated Types

type BaseBackend SqlWriteBackend |
Instance details Defined in Database.Persist.Sql.Types.Internal type BaseBackend SqlWriteBackend = SqlBackend

Methods

persistBackend :: SqlWriteBackend -> BaseBackend SqlWriteBackend #

HasPersistBackend SqlBackend # |

Instance details

Defined in Database.Persist.SqlBackend.Internal

Associated Types

type BaseBackend SqlBackend |
Instance details Defined in Database.Persist.SqlBackend.Internal type BaseBackend SqlBackend = SqlBackend

Methods

persistBackend :: SqlBackend -> BaseBackend SqlBackend #

(BackendCompatible b s, HasPersistBackend b) => HasPersistBackend (Compatible b s) # |

Instance details

Defined in Database.Persist.Compatible.Types

Associated Types

type BaseBackend (Compatible b s) |
Instance details Defined in Database.Persist.Compatible.Types type BaseBackend (Compatible b s) = BaseBackend b

Methods

persistBackend :: Compatible b s -> BaseBackend (Compatible b s) #

class HasPersistBackend backend => IsPersistBackend backend where #

Class which witnesses that `backend` is essentially the same as `BaseBackend backend`. That is, they're isomorphic and `backend` is just some wrapper over `BaseBackend backend`.

Methods

mkPersistBackend :: BaseBackend backend -> backend #

This function is how we actually construct and tag a backend as having read or write capabilities. It should be used carefully and only when actually constructing a `backend`. Careless use allows us to accidentally run a write query against a read-only database.

#### Instances

Instances details

IsPersistBackend SqlReadBackend # |
Instance details Defined in Database.Persist.Sql.Types.Internal Methods mkPersistBackend :: BaseBackend SqlReadBackend -> SqlReadBackend #
IsPersistBackend SqlWriteBackend # |
Instance details Defined in Database.Persist.Sql.Types.Internal Methods mkPersistBackend :: BaseBackend SqlWriteBackend -> SqlWriteBackend #
IsPersistBackend SqlBackend # |
Instance details Defined in Database.Persist.SqlBackend.Internal Methods mkPersistBackend :: BaseBackend SqlBackend -> SqlBackend #

newtype SqlReadBackend #

An SQL backend which can only handle read queries

The constructor was exposed in 2.10.0.

Constructors

SqlReadBackend |

Fields

- unSqlReadBackend :: SqlBackend

#### Instances

Instances details

PersistQueryRead SqlReadBackend # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistQuery

Methods

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

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

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

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

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

HasPersistBackend SqlReadBackend # |

Instance details

Defined in Database.Persist.Sql.Types.Internal

Associated Types

type BaseBackend SqlReadBackend |
Instance details Defined in Database.Persist.Sql.Types.Internal type BaseBackend SqlReadBackend = SqlBackend

Methods

persistBackend :: SqlReadBackend -> BaseBackend SqlReadBackend #

IsPersistBackend SqlReadBackend # |
Instance details Defined in Database.Persist.Sql.Types.Internal Methods mkPersistBackend :: BaseBackend SqlReadBackend -> SqlReadBackend #
PersistCore SqlReadBackend # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Associated Types

newtype BackendKey SqlReadBackend |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

newtype BackendKey SqlReadBackend = SqlReadBackendKey {

- unSqlReadBackendKey :: Int64

}

PersistStoreRead SqlReadBackend # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Methods

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

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

PersistUniqueRead SqlReadBackend # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistUnique

Methods

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

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

BackendCompatible SqlBackend SqlReadBackend # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods projectBackend :: SqlReadBackend -> SqlBackend #
FromJSON (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods parseJSON :: Value -> Parser (BackendKey SqlReadBackend) # parseJSONList :: Value -> Parser [BackendKey SqlReadBackend] # omittedField :: Maybe (BackendKey SqlReadBackend) #
ToJSON (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toJSON :: BackendKey SqlReadBackend -> Value # toEncoding :: BackendKey SqlReadBackend -> Encoding # toJSONList :: [BackendKey SqlReadBackend] -> Value # toEncodingList :: [BackendKey SqlReadBackend] -> Encoding # omitField :: BackendKey SqlReadBackend -> Bool #
Bounded (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods minBound :: BackendKey SqlReadBackend # maxBound :: BackendKey SqlReadBackend #
Enum (BackendKey SqlReadBackend) # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Methods

succ :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend #

pred :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend #

toEnum :: Int -> BackendKey SqlReadBackend #

fromEnum :: BackendKey SqlReadBackend -> Int #

enumFrom :: BackendKey SqlReadBackend -> [BackendKey SqlReadBackend] #

enumFromThen :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> [BackendKey SqlReadBackend] #

enumFromTo :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> [BackendKey SqlReadBackend] #

enumFromThenTo :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> [BackendKey SqlReadBackend] #

Generic (BackendKey SqlReadBackend) # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Associated Types

type Rep (BackendKey SqlReadBackend) |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore type Rep (BackendKey SqlReadBackend) = D1 ('MetaData "BackendKey" "Database.Persist.Sql.Orphan.PersistStore" "persistent-2.14.6.3-JVVGzpBhz0IC64DMc3fyym" 'True) (C1 ('MetaCons "SqlReadBackendKey" 'PrefixI 'True) (S1 ('MetaSel ('Just "unSqlReadBackendKey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))

Methods

from :: BackendKey SqlReadBackend -> Rep (BackendKey SqlReadBackend) x #

to :: Rep (BackendKey SqlReadBackend) x -> BackendKey SqlReadBackend #

Num (BackendKey SqlReadBackend) # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Methods

(+) :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend #

(-) :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend #

(*) :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend #

negate :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend #

abs :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend #

signum :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend #

fromInteger :: Integer -> BackendKey SqlReadBackend #

Read (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods readsPrec :: Int -> ReadS (BackendKey SqlReadBackend) # readList :: ReadS [BackendKey SqlReadBackend] # readPrec :: ReadPrec (BackendKey SqlReadBackend) # readListPrec :: ReadPrec [BackendKey SqlReadBackend] #
Integral (BackendKey SqlReadBackend) # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Methods

quot :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend #

rem :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend #

div :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend #

mod :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend #

quotRem :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> (BackendKey SqlReadBackend, BackendKey SqlReadBackend) #

divMod :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> (BackendKey SqlReadBackend, BackendKey SqlReadBackend) #

toInteger :: BackendKey SqlReadBackend -> Integer #

Real (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toRational :: BackendKey SqlReadBackend -> Rational #
Show (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods showsPrec :: Int -> BackendKey SqlReadBackend -> ShowS # show :: BackendKey SqlReadBackend -> String # showList :: [BackendKey SqlReadBackend] -> ShowS #
Eq (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods (==) :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> Bool # (/=) :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> Bool #
Ord (BackendKey SqlReadBackend) # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Methods

compare :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> Ordering #

(<) :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> Bool #

(<=) :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> Bool #

(>) :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> Bool #

(>=) :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> Bool #

max :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend #

min :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend #

FromHttpApiData (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods parseUrlPiece :: Text -> Either Text (BackendKey SqlReadBackend) # parseHeader :: ByteString -> Either Text (BackendKey SqlReadBackend) # parseQueryParam :: Text -> Either Text (BackendKey SqlReadBackend) #
ToHttpApiData (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toUrlPiece :: BackendKey SqlReadBackend -> Text # toEncodedUrlPiece :: BackendKey SqlReadBackend -> Builder # toHeader :: BackendKey SqlReadBackend -> ByteString # toQueryParam :: BackendKey SqlReadBackend -> Text # toEncodedQueryParam :: BackendKey SqlReadBackend -> Builder #
PathPiece (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods fromPathPiece :: Text -> Maybe (BackendKey SqlReadBackend) # toPathPiece :: BackendKey SqlReadBackend -> Text #
PersistField (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toPersistValue :: BackendKey SqlReadBackend -> PersistValue # fromPersistValue :: PersistValue -> Either Text (BackendKey SqlReadBackend) #
PersistFieldSql (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods sqlType :: Proxy (BackendKey SqlReadBackend) -> SqlType #
newtype BackendKey SqlReadBackend # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

newtype BackendKey SqlReadBackend = SqlReadBackendKey {

- unSqlReadBackendKey :: Int64

}

type BaseBackend SqlReadBackend # |
Instance details Defined in Database.Persist.Sql.Types.Internal type BaseBackend SqlReadBackend = SqlBackend
type Rep (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore type Rep (BackendKey SqlReadBackend) = D1 ('MetaData "BackendKey" "Database.Persist.Sql.Orphan.PersistStore" "persistent-2.14.6.3-JVVGzpBhz0IC64DMc3fyym" 'True) (C1 ('MetaCons "SqlReadBackendKey" 'PrefixI 'True) (S1 ('MetaSel ('Just "unSqlReadBackendKey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))

newtype SqlWriteBackend #

An SQL backend which can handle read or write queries

The constructor was exposed in 2.10.0

Constructors

SqlWriteBackend |

Fields

- unSqlWriteBackend :: SqlBackend

#### Instances

Instances details

PersistQueryRead SqlWriteBackend # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistQuery

Methods

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

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

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

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

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

PersistQueryWrite SqlWriteBackend # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistQuery

Methods

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

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

HasPersistBackend SqlWriteBackend # |

Instance details

Defined in Database.Persist.Sql.Types.Internal

Associated Types

type BaseBackend SqlWriteBackend |
Instance details Defined in Database.Persist.Sql.Types.Internal type BaseBackend SqlWriteBackend = SqlBackend

Methods

persistBackend :: SqlWriteBackend -> BaseBackend SqlWriteBackend #

IsPersistBackend SqlWriteBackend # |
Instance details Defined in Database.Persist.Sql.Types.Internal Methods mkPersistBackend :: BaseBackend SqlWriteBackend -> SqlWriteBackend #
PersistCore SqlWriteBackend # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Associated Types

newtype BackendKey SqlWriteBackend |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

newtype BackendKey SqlWriteBackend = SqlWriteBackendKey {

- unSqlWriteBackendKey :: Int64

}

PersistStoreRead SqlWriteBackend # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Methods

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

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

PersistStoreWrite SqlWriteBackend # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Methods

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

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

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

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

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

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

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

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

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

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

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

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

PersistUniqueRead SqlWriteBackend # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistUnique

Methods

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

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

PersistUniqueWrite SqlWriteBackend # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistUnique

Methods

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

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

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

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

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

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

BackendCompatible SqlBackend SqlWriteBackend # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods projectBackend :: SqlWriteBackend -> SqlBackend #
FromJSON (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods parseJSON :: Value -> Parser (BackendKey SqlWriteBackend) # parseJSONList :: Value -> Parser [BackendKey SqlWriteBackend] # omittedField :: Maybe (BackendKey SqlWriteBackend) #
ToJSON (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toJSON :: BackendKey SqlWriteBackend -> Value # toEncoding :: BackendKey SqlWriteBackend -> Encoding # toJSONList :: [BackendKey SqlWriteBackend] -> Value # toEncodingList :: [BackendKey SqlWriteBackend] -> Encoding # omitField :: BackendKey SqlWriteBackend -> Bool #
Bounded (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods minBound :: BackendKey SqlWriteBackend # maxBound :: BackendKey SqlWriteBackend #
Enum (BackendKey SqlWriteBackend) # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Methods

succ :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend #

pred :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend #

toEnum :: Int -> BackendKey SqlWriteBackend #

fromEnum :: BackendKey SqlWriteBackend -> Int #

enumFrom :: BackendKey SqlWriteBackend -> [BackendKey SqlWriteBackend] #

enumFromThen :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> [BackendKey SqlWriteBackend] #

enumFromTo :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> [BackendKey SqlWriteBackend] #

enumFromThenTo :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> [BackendKey SqlWriteBackend] #

Generic (BackendKey SqlWriteBackend) # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Associated Types

type Rep (BackendKey SqlWriteBackend) |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore type Rep (BackendKey SqlWriteBackend) = D1 ('MetaData "BackendKey" "Database.Persist.Sql.Orphan.PersistStore" "persistent-2.14.6.3-JVVGzpBhz0IC64DMc3fyym" 'True) (C1 ('MetaCons "SqlWriteBackendKey" 'PrefixI 'True) (S1 ('MetaSel ('Just "unSqlWriteBackendKey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))

Methods

from :: BackendKey SqlWriteBackend -> Rep (BackendKey SqlWriteBackend) x #

to :: Rep (BackendKey SqlWriteBackend) x -> BackendKey SqlWriteBackend #

Num (BackendKey SqlWriteBackend) # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Methods

(+) :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend #

(-) :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend #

(*) :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend #

negate :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend #

abs :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend #

signum :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend #

fromInteger :: Integer -> BackendKey SqlWriteBackend #

Read (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods readsPrec :: Int -> ReadS (BackendKey SqlWriteBackend) # readList :: ReadS [BackendKey SqlWriteBackend] # readPrec :: ReadPrec (BackendKey SqlWriteBackend) # readListPrec :: ReadPrec [BackendKey SqlWriteBackend] #
Integral (BackendKey SqlWriteBackend) # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Methods

quot :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend #

rem :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend #

div :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend #

mod :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend #

quotRem :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> (BackendKey SqlWriteBackend, BackendKey SqlWriteBackend) #

divMod :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> (BackendKey SqlWriteBackend, BackendKey SqlWriteBackend) #

toInteger :: BackendKey SqlWriteBackend -> Integer #

Real (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toRational :: BackendKey SqlWriteBackend -> Rational #
Show (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods showsPrec :: Int -> BackendKey SqlWriteBackend -> ShowS # show :: BackendKey SqlWriteBackend -> String # showList :: [BackendKey SqlWriteBackend] -> ShowS #
Eq (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods (==) :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> Bool # (/=) :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> Bool #
Ord (BackendKey SqlWriteBackend) # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Methods

compare :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> Ordering #

(<) :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> Bool #

(<=) :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> Bool #

(>) :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> Bool #

(>=) :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> Bool #

max :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend #

min :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend #

FromHttpApiData (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods parseUrlPiece :: Text -> Either Text (BackendKey SqlWriteBackend) # parseHeader :: ByteString -> Either Text (BackendKey SqlWriteBackend) # parseQueryParam :: Text -> Either Text (BackendKey SqlWriteBackend) #
ToHttpApiData (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toUrlPiece :: BackendKey SqlWriteBackend -> Text # toEncodedUrlPiece :: BackendKey SqlWriteBackend -> Builder # toHeader :: BackendKey SqlWriteBackend -> ByteString # toQueryParam :: BackendKey SqlWriteBackend -> Text # toEncodedQueryParam :: BackendKey SqlWriteBackend -> Builder #
PathPiece (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods fromPathPiece :: Text -> Maybe (BackendKey SqlWriteBackend) # toPathPiece :: BackendKey SqlWriteBackend -> Text #
PersistField (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toPersistValue :: BackendKey SqlWriteBackend -> PersistValue # fromPersistValue :: PersistValue -> Either Text (BackendKey SqlWriteBackend) #
PersistFieldSql (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods sqlType :: Proxy (BackendKey SqlWriteBackend) -> SqlType #
newtype BackendKey SqlWriteBackend # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

newtype BackendKey SqlWriteBackend = SqlWriteBackendKey {

- unSqlWriteBackendKey :: Int64

}

type BaseBackend SqlWriteBackend # |
Instance details Defined in Database.Persist.Sql.Types.Internal type BaseBackend SqlWriteBackend = SqlBackend
type Rep (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore type Rep (BackendKey SqlWriteBackend) = D1 ('MetaData "BackendKey" "Database.Persist.Sql.Orphan.PersistStore" "persistent-2.14.6.3-JVVGzpBhz0IC64DMc3fyym" 'True) (C1 ('MetaCons "SqlWriteBackendKey" 'PrefixI 'True) (S1 ('MetaSel ('Just "unSqlWriteBackendKey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))

readToUnknown :: forall (m :: Type -> Type) a. Monad m => ReaderT SqlReadBackend m a -> ReaderT SqlBackend m a #

Useful for running a read query against a backend with unknown capabilities.

readToWrite :: forall (m :: Type -> Type) a. Monad m => ReaderT SqlReadBackend m a -> ReaderT SqlWriteBackend m a #

Useful for running a read query against a backend with read and write capabilities.

writeToUnknown :: forall (m :: Type -> Type) a. Monad m => ReaderT SqlWriteBackend m a -> ReaderT SqlBackend m a #

Useful for running a write query against an untagged backend with unknown capabilities.

type LogFunc = Loc -> LogSource -> LogLevel -> LogStr -> IO () #

data InsertSqlResult #

Constructors

ISRSingle Text |
ISRInsertGet Text Text |
ISRManyKeys Text [PersistValue] |

data Statement #

A `Statement` is a representation of a database query that has been prepared and stored on the server side.

Constructors

Statement |

Fields

- stmtFinalize :: IO ()
- stmtReset :: IO ()
- stmtExecute :: [PersistValue] -> IO Int64
- stmtQuery :: forall (m :: Type -> Type). MonadIO m => [PersistValue] -> Acquire (ConduitM () [PersistValue] m ())

data IsolationLevel #

Please refer to the documentation for the database in question for a full overview of the semantics of the varying isloation levels

Constructors

ReadUncommitted |
ReadCommitted |
RepeatableRead |
Serializable |

#### Instances

Instances details

Bounded IsolationLevel # |
Instance details Defined in Database.Persist.SqlBackend.Internal.IsolationLevel Methods minBound :: IsolationLevel # maxBound :: IsolationLevel #
Enum IsolationLevel # |

Instance details

Defined in Database.Persist.SqlBackend.Internal.IsolationLevel

Methods

succ :: IsolationLevel -> IsolationLevel #

pred :: IsolationLevel -> IsolationLevel #

toEnum :: Int -> IsolationLevel #

fromEnum :: IsolationLevel -> Int #

enumFrom :: IsolationLevel -> [IsolationLevel] #

enumFromThen :: IsolationLevel -> IsolationLevel -> [IsolationLevel] #

enumFromTo :: IsolationLevel -> IsolationLevel -> [IsolationLevel] #

enumFromThenTo :: IsolationLevel -> IsolationLevel -> IsolationLevel -> [IsolationLevel] #

Show IsolationLevel # |
Instance details Defined in Database.Persist.SqlBackend.Internal.IsolationLevel Methods showsPrec :: Int -> IsolationLevel -> ShowS # show :: IsolationLevel -> String # showList :: [IsolationLevel] -> ShowS #
Eq IsolationLevel # |
Instance details Defined in Database.Persist.SqlBackend.Internal.IsolationLevel Methods (==) :: IsolationLevel -> IsolationLevel -> Bool # (/=) :: IsolationLevel -> IsolationLevel -> Bool #
Ord IsolationLevel # |

Instance details

Defined in Database.Persist.SqlBackend.Internal.IsolationLevel

Methods

compare :: IsolationLevel -> IsolationLevel -> Ordering #

(<) :: IsolationLevel -> IsolationLevel -> Bool #

(<=) :: IsolationLevel -> IsolationLevel -> Bool #

(>) :: IsolationLevel -> IsolationLevel -> Bool #

(>=) :: IsolationLevel -> IsolationLevel -> Bool #

max :: IsolationLevel -> IsolationLevel -> IsolationLevel #

min :: IsolationLevel -> IsolationLevel -> IsolationLevel #

makeIsolationLevelStatement :: (Monoid s, IsString s) => IsolationLevel -> s #

data SqlBackend #

A `SqlBackend` represents a handle or connection to a database. It contains functions and values that allow databases to have more optimized implementations, as well as references that benefit performance and sharing.

Instead of using the `SqlBackend` constructor directly, use the `mkSqlBackend` function.

A `SqlBackend` is *not* thread-safe. You should not assume that a `SqlBackend` can be shared among threads and run concurrent queries. This *will* result in problems. Instead, you should create a ``Pool` `SqlBackend``, known as a `ConnectionPool`, and pass that around in multi-threaded applications.

To run actions in the `persistent` library, you should use the `runSqlConn` function. If you're using a multithreaded application, use the `runSqlPool` function.

Constructors

SqlBackend |

Fields

- connPrepare :: Text -> IO Statement

  This function should prepare a `Statement` in the target database, which should allow for efficient query reuse.

- connInsertSql :: EntityDef -> [PersistValue] -> InsertSqlResult

  This function generates the SQL and values necessary for performing an insert against the database.

- connInsertManySql :: Maybe (EntityDef -> [[PersistValue]] -> InsertSqlResult)

  SQL for inserting many rows and returning their primary keys, for backends that support this functionality. If `Nothing`, rows will be inserted one-at-a-time using `connInsertSql`.

- connUpsertSql :: Maybe (EntityDef -> NonEmpty (FieldNameHS, FieldNameDB) -> Text -> Text)

  Some databases support performing UPSERT _and_ RETURN entity in a single call.

  This field when set will be used to generate the UPSERT+RETURN sql given * an entity definition * updates to be run on unique key(s) collision

  When left as `Nothing`, we find the unique key from entity def before * trying to fetch an entity by said key * perform an update when result found, else issue an insert * return new entity from db

  Since: 2.6

- connPutManySql :: Maybe (EntityDef -> Int -> Text)

  Some databases support performing bulk UPSERT, specifically "insert or replace many records" in a single call.

  This field when set, given * an entity definition * number of records to be inserted should produce a PUT MANY sql with placeholders for records

  When left as `Nothing`, we default to using `defaultPutMany`.

  Since: 2.8.1

- connStmtMap :: StatementCache

  A reference to the cache of statements. `Statement`s are keyed by the `Text` queries that generated them.

- connClose :: IO ()

  Close the underlying connection.

- connMigrateSql :: [EntityDef] -> (Text -> IO Statement) -> EntityDef -> IO (Either [Text] [(Bool, Text)])

  This function returns the migrations required to include the `EntityDef` parameter in the `[`EntityDef`]` database. This might include creating a new table if the entity is not present, or altering an existing table if it is.

- connBegin :: (Text -> IO Statement) -> Maybe IsolationLevel -> IO ()

  A function to begin a transaction for the underlying database.

- connCommit :: (Text -> IO Statement) -> IO ()

  A function to commit a transaction to the underlying database.

- connRollback :: (Text -> IO Statement) -> IO ()

  A function to roll back a transaction on the underlying database.

- connEscapeFieldName :: FieldNameDB -> Text

  A function to extract and escape the name of the column corresponding to the provided field.

  Since: 2.12.0.0

- connEscapeTableName :: EntityDef -> Text

  A function to extract and escape the name of the table corresponding to the provided entity. PostgreSQL uses this to support schemas.

  Since: 2.12.0.0

- connEscapeRawName :: Text -> Text

  A function to escape raw DB identifiers. MySQL uses backticks, while PostgreSQL uses quotes, and so on.

  Since: 2.12.0.0

- connNoLimit :: Text
- connRDBMS :: Text

  A tag displaying what database the `SqlBackend` is for. Can be used to differentiate features in downstream libraries for different database backends.

- connLimitOffset :: (Int, Int) -> Text -> Text

  Attach a 'LIMIT/OFFSET' clause to a SQL query. Note that LIMIT/OFFSET is problematic for performance, and indexed range queries are the superior way to offer pagination.

- connLogFunc :: LogFunc

  A log function for the `SqlBackend` to use.

- connMaxParams :: Maybe Int

  Some databases (probably only Sqlite) have a limit on how many question-mark parameters may be used in a statement

  Since: 2.6.1

- connRepsertManySql :: Maybe (EntityDef -> Int -> Text)

  Some databases support performing bulk an atomic+bulk INSERT where constraint conflicting entities can replace existing entities.

  This field when set, given * an entity definition * number of records to be inserted should produce a INSERT sql with placeholders for primary+record fields

  When left as `Nothing`, we default to using `defaultRepsertMany`.

  Since: 2.9.0

- connVault :: Vault

  Carry arbitrary payloads for the connection that may be used to propagate information into hooks.

- connHooks :: SqlBackendHooks

  Instrumentation hooks that may be used to track the behaviour of a backend.

#### Instances

Instances details

PersistQueryRead SqlBackend # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistQuery

Methods

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

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

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

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

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

PersistQueryWrite SqlBackend # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistQuery Methods updateWhere :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record SqlBackend) => [Filter record] -> [Update record] -> ReaderT SqlBackend m () # deleteWhere :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record SqlBackend) => [Filter record] -> ReaderT SqlBackend m () #
HasPersistBackend SqlBackend # |

Instance details

Defined in Database.Persist.SqlBackend.Internal

Associated Types

type BaseBackend SqlBackend |
Instance details Defined in Database.Persist.SqlBackend.Internal type BaseBackend SqlBackend = SqlBackend

Methods

persistBackend :: SqlBackend -> BaseBackend SqlBackend #

IsPersistBackend SqlBackend # |
Instance details Defined in Database.Persist.SqlBackend.Internal Methods mkPersistBackend :: BaseBackend SqlBackend -> SqlBackend #
PersistCore SqlBackend # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Associated Types

newtype BackendKey SqlBackend |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

newtype BackendKey SqlBackend = SqlBackendKey {

- unSqlBackendKey :: Int64

}

PersistStoreRead SqlBackend # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods get :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlBackend) => Key record -> ReaderT SqlBackend m (Maybe record) # getMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlBackend) => [Key record] -> ReaderT SqlBackend m (Map (Key record) record) #
PersistStoreWrite SqlBackend # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Methods

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

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

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

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

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

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

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

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

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

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

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

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

PersistUniqueRead SqlBackend # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistUnique Methods getBy :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlBackend) => Unique record -> ReaderT SqlBackend m (Maybe (Entity record)) # existsBy :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlBackend) => Unique record -> ReaderT SqlBackend m Bool #
PersistUniqueWrite SqlBackend # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistUnique

Methods

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

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

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

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

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

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

BackendCompatible SqlBackend SqlReadBackend # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods projectBackend :: SqlReadBackend -> SqlBackend #
BackendCompatible SqlBackend SqlWriteBackend # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods projectBackend :: SqlWriteBackend -> SqlBackend #
BackendCompatible SqlBackend SqlBackend # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods projectBackend :: SqlBackend -> SqlBackend #
FromJSON (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods parseJSON :: Value -> Parser (BackendKey SqlBackend) # parseJSONList :: Value -> Parser [BackendKey SqlBackend] # omittedField :: Maybe (BackendKey SqlBackend) #
ToJSON (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toJSON :: BackendKey SqlBackend -> Value # toEncoding :: BackendKey SqlBackend -> Encoding # toJSONList :: [BackendKey SqlBackend] -> Value # toEncodingList :: [BackendKey SqlBackend] -> Encoding # omitField :: BackendKey SqlBackend -> Bool #
Bounded (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods minBound :: BackendKey SqlBackend # maxBound :: BackendKey SqlBackend #
Enum (BackendKey SqlBackend) # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Methods

succ :: BackendKey SqlBackend -> BackendKey SqlBackend #

pred :: BackendKey SqlBackend -> BackendKey SqlBackend #

toEnum :: Int -> BackendKey SqlBackend #

fromEnum :: BackendKey SqlBackend -> Int #

enumFrom :: BackendKey SqlBackend -> [BackendKey SqlBackend] #

enumFromThen :: BackendKey SqlBackend -> BackendKey SqlBackend -> [BackendKey SqlBackend] #

enumFromTo :: BackendKey SqlBackend -> BackendKey SqlBackend -> [BackendKey SqlBackend] #

enumFromThenTo :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend -> [BackendKey SqlBackend] #

Generic (BackendKey SqlBackend) # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Associated Types

type Rep (BackendKey SqlBackend) |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore type Rep (BackendKey SqlBackend) = D1 ('MetaData "BackendKey" "Database.Persist.Sql.Orphan.PersistStore" "persistent-2.14.6.3-JVVGzpBhz0IC64DMc3fyym" 'True) (C1 ('MetaCons "SqlBackendKey" 'PrefixI 'True) (S1 ('MetaSel ('Just "unSqlBackendKey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))

Methods

from :: BackendKey SqlBackend -> Rep (BackendKey SqlBackend) x #

to :: Rep (BackendKey SqlBackend) x -> BackendKey SqlBackend #

Num (BackendKey SqlBackend) # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Methods

(+) :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend #

(-) :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend #

(*) :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend #

negate :: BackendKey SqlBackend -> BackendKey SqlBackend #

abs :: BackendKey SqlBackend -> BackendKey SqlBackend #

signum :: BackendKey SqlBackend -> BackendKey SqlBackend #

fromInteger :: Integer -> BackendKey SqlBackend #

Read (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods readsPrec :: Int -> ReadS (BackendKey SqlBackend) # readList :: ReadS [BackendKey SqlBackend] # readPrec :: ReadPrec (BackendKey SqlBackend) # readListPrec :: ReadPrec [BackendKey SqlBackend] #
Integral (BackendKey SqlBackend) # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Methods

quot :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend #

rem :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend #

div :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend #

mod :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend #

quotRem :: BackendKey SqlBackend -> BackendKey SqlBackend -> (BackendKey SqlBackend, BackendKey SqlBackend) #

divMod :: BackendKey SqlBackend -> BackendKey SqlBackend -> (BackendKey SqlBackend, BackendKey SqlBackend) #

toInteger :: BackendKey SqlBackend -> Integer #

Real (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toRational :: BackendKey SqlBackend -> Rational #
Show (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods showsPrec :: Int -> BackendKey SqlBackend -> ShowS # show :: BackendKey SqlBackend -> String # showList :: [BackendKey SqlBackend] -> ShowS #
Eq (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods (==) :: BackendKey SqlBackend -> BackendKey SqlBackend -> Bool # (/=) :: BackendKey SqlBackend -> BackendKey SqlBackend -> Bool #
Ord (BackendKey SqlBackend) # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Methods

compare :: BackendKey SqlBackend -> BackendKey SqlBackend -> Ordering #

(<) :: BackendKey SqlBackend -> BackendKey SqlBackend -> Bool #

(<=) :: BackendKey SqlBackend -> BackendKey SqlBackend -> Bool #

(>) :: BackendKey SqlBackend -> BackendKey SqlBackend -> Bool #

(>=) :: BackendKey SqlBackend -> BackendKey SqlBackend -> Bool #

max :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend #

min :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend #

FromHttpApiData (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods parseUrlPiece :: Text -> Either Text (BackendKey SqlBackend) # parseHeader :: ByteString -> Either Text (BackendKey SqlBackend) # parseQueryParam :: Text -> Either Text (BackendKey SqlBackend) #
ToHttpApiData (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toUrlPiece :: BackendKey SqlBackend -> Text # toEncodedUrlPiece :: BackendKey SqlBackend -> Builder # toHeader :: BackendKey SqlBackend -> ByteString # toQueryParam :: BackendKey SqlBackend -> Text # toEncodedQueryParam :: BackendKey SqlBackend -> Builder #
PathPiece (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods fromPathPiece :: Text -> Maybe (BackendKey SqlBackend) # toPathPiece :: BackendKey SqlBackend -> Text #
PersistField (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toPersistValue :: BackendKey SqlBackend -> PersistValue # fromPersistValue :: PersistValue -> Either Text (BackendKey SqlBackend) #
PersistFieldSql (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods sqlType :: Proxy (BackendKey SqlBackend) -> SqlType #
newtype BackendKey SqlBackend # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

newtype BackendKey SqlBackend = SqlBackendKey {

- unSqlBackendKey :: Int64

}

type BaseBackend SqlBackend # |
Instance details Defined in Database.Persist.SqlBackend.Internal type BaseBackend SqlBackend = SqlBackend
type Rep (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore type Rep (BackendKey SqlBackend) = D1 ('MetaData "BackendKey" "Database.Persist.Sql.Orphan.PersistStore" "persistent-2.14.6.3-JVVGzpBhz0IC64DMc3fyym" 'True) (C1 ('MetaCons "SqlBackendKey" 'PrefixI 'True) (S1 ('MetaSel ('Just "unSqlBackendKey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))

type SqlBackendCanRead backend = (BackendCompatible SqlBackend backend, PersistQueryRead backend, PersistStoreRead backend, PersistUniqueRead backend) #

A constraint synonym which witnesses that a backend is SQL and can run read queries.

type SqlBackendCanWrite backend = (SqlBackendCanRead backend, PersistQueryWrite backend, PersistStoreWrite backend, PersistUniqueWrite backend) #

A constraint synonym which witnesses that a backend is SQL and can run read and write queries.

type SqlReadT (m :: Type -> Type) a = forall backend. SqlBackendCanRead backend => ReaderT backend m a #

Like `SqlPersistT` but compatible with any SQL backend which can handle read queries.

type SqlWriteT (m :: Type -> Type) a = forall backend. SqlBackendCanWrite backend => ReaderT backend m a #

Like `SqlPersistT` but compatible with any SQL backend which can handle read and write queries.

type IsSqlBackend backend = (IsPersistBackend backend, BaseBackend backend ~ SqlBackend) #

A backend which is a wrapper around `SqlBackend`.

newtype SqlBackendHooks #

Constructors

SqlBackendHooks |

Fields

- hookGetStatement :: SqlBackend -> Text -> Statement -> IO Statement