Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Database.Persist.Sql.Lifted.Persistent
Description
Wrappers that apply liftSql
to Persistent utilities of the same name.
Synopsis
- checkUnique :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => a -> m (Maybe (Unique a))
- checkUniqueUpdateable :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => Entity a -> m (Maybe (Unique a))
- count :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => [Filter a] -> m Int
- delete :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => Key a -> m ()
- deleteBy :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => Unique a -> m ()
- deleteWhere :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => [Filter a] -> m ()
- deleteWhereCount :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => [Filter a] -> m Int64
- exists :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => [Filter a] -> m Bool
- existsBy :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => Unique a -> m Bool
- get :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => Key a -> m (Maybe a)
- getBy :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => Unique a -> m (Maybe (Entity a))
- getByValue :: forall a m. (AtLeastOneUniqueKey a, HasCallStack, MonadSqlBackend m, PersistEntityBackend a ~ SqlBackend) => a -> m (Maybe (Entity a))
- getEntity :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => Key a -> m (Maybe (Entity a))
- getFieldName :: forall a t m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => EntityField a t -> m Text
- getJust :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => Key a -> m a
- getJustEntity :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => Key a -> m (Entity a)
- getMany :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => [Key a] -> m (Map (Key a) a)
- getTableName :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a) => a -> m Text
- insert :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend, SafeToInsert a) => a -> m (Key a)
- insert_ :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend, SafeToInsert a) => a -> m ()
- insertBy :: forall a m. (AtLeastOneUniqueKey a, HasCallStack, MonadSqlBackend m, PersistEntityBackend a ~ SqlBackend, SafeToInsert a) => a -> m (Either (Entity a) (Key a))
- insertEntity :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend, SafeToInsert a) => a -> m (Entity a)
- insertEntityMany :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => [Entity a] -> m ()
- insertKey :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => Key a -> a -> m ()
- insertMany :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend, SafeToInsert a) => [a] -> m [Key a]
- insertMany_ :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend, SafeToInsert a) => [a] -> m ()
- insertRecord :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend, SafeToInsert a) => a -> m a
- insertUnique :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend, SafeToInsert a) => a -> m (Maybe (Key a))
- insertUnique_ :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend, SafeToInsert a) => a -> m (Maybe ())
- insertUniqueEntity :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend, SafeToInsert a) => a -> m (Maybe (Entity a))
- onlyUnique :: forall a m. (HasCallStack, MonadSqlBackend m, OnlyOneUniqueKey a, PersistEntityBackend a ~ SqlBackend) => a -> m (Unique a)
- putMany :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend, SafeToInsert a) => [a] -> m ()
- rawExecute :: forall m. (HasCallStack, MonadSqlBackend m) => Text -> [PersistValue] -> m ()
- rawExecuteCount :: forall m. (HasCallStack, MonadSqlBackend m) => Text -> [PersistValue] -> m Int64
- rawSql :: forall a m. (HasCallStack, MonadSqlBackend m, RawSql a) => Text -> [PersistValue] -> m [a]
- replace :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => Key a -> a -> m ()
- replaceUnique :: forall a m. (Eq (Unique a), HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => Key a -> a -> m (Maybe (Unique a))
- repsert :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => Key a -> a -> m ()
- repsertMany :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => [(Key a, a)] -> m ()
- selectFirst :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => [Filter a] -> [SelectOpt a] -> m (Maybe (Entity a))
- selectKeysList :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => [Filter a] -> [SelectOpt a] -> m [Key a]
- selectList :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => [Filter a] -> [SelectOpt a] -> m [Entity a]
- transactionSave :: forall m. (HasCallStack, MonadSqlBackend m) => m ()
- transactionSaveWithIsolation :: forall m. (HasCallStack, MonadSqlBackend m) => IsolationLevel -> m ()
- transactionUndo :: forall m. (HasCallStack, MonadSqlBackend m) => m ()
- transactionUndoWithIsolation :: forall m. (HasCallStack, MonadSqlBackend m) => IsolationLevel -> m ()
- update :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => Key a -> [Update a] -> m ()
- updateGet :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => Key a -> [Update a] -> m a
- updateWhere :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => [Filter a] -> [Update a] -> m ()
- updateWhereCount :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => [Filter a] -> [Update a] -> m Int64
- upsert :: forall a m. (HasCallStack, MonadSqlBackend m, OnlyOneUniqueKey a, PersistEntityBackend a ~ SqlBackend, SafeToInsert a) => a -> [Update a] -> m (Entity a)
- upsertBy :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend, SafeToInsert a) => Unique a -> a -> [Update a] -> m (Entity a)
Documentation
Arguments
:: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) | |
=> a | |
-> m (Maybe (Unique a)) |
|
Check whether there are any conflicts for unique keys with this entity and existing entities in the database
checkUniqueUpdateable Source #
Arguments
:: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) | |
=> Entity a | |
-> m (Maybe (Unique a)) |
|
Check whether there are any conflicts for unique keys with this entity and existing entities in the database
This is useful for updating because it ignores conflicts when the particular entity already exists.
Arguments
:: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) | |
=> [Filter a] | If you provide multiple values in the list, the conditions are ANDed together. |
-> m Int |
The total number of records fulfilling the given criteria
delete :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => Key a -> m () Source #
Delete a specific record by identifier
Does nothing if record does not exist.
deleteBy :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => Unique a -> m () Source #
Delete a specific record by unique key
Does nothing if no record matches.
Arguments
:: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) | |
=> [Filter a] | If you provide multiple values in the list, the conditions are ANDed together. |
-> m () |
Delete all records matching the given criteria
Arguments
:: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) | |
=> [Filter a] | If you provide multiple values in the list, the conditions are ANDed together. |
-> m Int64 | The number of rows affected |
Delete all records matching the given criteria
Arguments
:: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) | |
=> [Filter a] | If you provide multiple values in the list, the conditions are ANDed together. |
-> m Bool |
Check if there is at least one record fulfilling the given criteria
existsBy :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => Unique a -> m Bool Source #
Check if a record with this unique key exists
get :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => Key a -> m (Maybe a) Source #
Get a record by identifier, if available
getBy :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => Unique a -> m (Maybe (Entity a)) Source #
Get a record by unique key, if available, returning both the identifier and the record
Arguments
:: forall a m. (AtLeastOneUniqueKey a, HasCallStack, MonadSqlBackend m, PersistEntityBackend a ~ SqlBackend) | |
=> a | |
-> m (Maybe (Entity a)) | A record matching one of the unique keys. |
getEntity :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => Key a -> m (Maybe (Entity a)) Source #
Get a record by identifier, if available
getFieldName :: forall a t m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => EntityField a t -> m Text Source #
Get the SQL string for the field that an EntityField
represents
getJust :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => Key a -> m a Source #
Get a record by identifier, if available, for a non-null (not Maybe
) foreign key
Unsafe unless your database is enforcing that the foreign key is valid.
getJustEntity :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => Key a -> m (Entity a) Source #
Get a record by identifier, if available, for a non-null (not Maybe
) foreign key
Unsafe unless your database is enforcing that the foreign key is valid.
getMany :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => [Key a] -> m (Map (Key a) a) Source #
Get many records by their respective identifiers, if available
getTableName :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a) => a -> m Text Source #
Get the SQL string for the table that a PersistEntity
represents
Arguments
:: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend, SafeToInsert a) | |
=> a | |
-> m (Key a) | The auto-increment ID that was generated |
Create a new record in the database
insert_ :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend, SafeToInsert a) => a -> m () Source #
Create a new record in the database
Arguments
:: forall a m. (AtLeastOneUniqueKey a, HasCallStack, MonadSqlBackend m, PersistEntityBackend a ~ SqlBackend, SafeToInsert a) | |
=> a | |
-> m (Either (Entity a) (Key a)) | If a duplicate exists in the database, it is returned as |
Insert a value, checking for conflicts with any unique constraints
insertEntity :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend, SafeToInsert a) => a -> m (Entity a) Source #
Create a new record in the database, returning an auto-increment ID and the inserted record
insertEntityMany :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => [Entity a] -> m () Source #
Create multiple records in the database, with specified keys
insertKey :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => Key a -> a -> m () Source #
Create a new record in the database using the given key
insertMany :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend, SafeToInsert a) => [a] -> m [Key a] Source #
Create multiple records in the database and return their Key
s
insertMany_ :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend, SafeToInsert a) => [a] -> m () Source #
Create multiple records in the database
Arguments
:: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend, SafeToInsert a) | |
=> a | |
-> m a | The record that was inserted |
Create a new record in the database
Arguments
:: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend, SafeToInsert a) | |
=> a | |
-> m (Maybe (Key a)) | An auto-increment ID, or |
Create a new record in the database
Arguments
:: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend, SafeToInsert a) | |
=> a | |
-> m (Maybe ()) | (), or |
Create a new record in the database
Arguments
:: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend, SafeToInsert a) | |
=> a | |
-> m (Maybe (Entity a)) | An auto-increment ID and the inserted record, or |
Create a new record in the database
onlyUnique :: forall a m. (HasCallStack, MonadSqlBackend m, OnlyOneUniqueKey a, PersistEntityBackend a ~ SqlBackend) => a -> m (Unique a) Source #
Return the single unique key for a record
Arguments
:: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend, SafeToInsert a) | |
=> [a] | A list of the records you want to insert or replace. |
-> m () |
Put many records into the database
- Insert new records that do not exist (or violate any unique constraints);
- Replace existing records (matching any unique constraint).
Arguments
:: forall m. (HasCallStack, MonadSqlBackend m) | |
=> Text | SQL statement, possibly with placeholders |
-> [PersistValue] | Values to fill the placeholders |
-> m () |
Execute a raw SQL statement
Arguments
:: forall m. (HasCallStack, MonadSqlBackend m) | |
=> Text | SQL statement, possibly with placeholders |
-> [PersistValue] | Values to fill the placeholders |
-> m Int64 | The number of rows modified |
Execute a raw SQL statement
Arguments
:: forall a m. (HasCallStack, MonadSqlBackend m, RawSql a) | |
=> Text | SQL statement, possibly with placeholders |
-> [PersistValue] | Values to fill the placeholders |
-> m [a] |
replace :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => Key a -> a -> m () Source #
Replace the record in the database with the given key
The result is undefined if such record does not exist.
Arguments
:: forall a m. (Eq (Unique a), HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) | |
=> Key a | |
-> a | |
-> m (Maybe (Unique a)) |
|
Attempt to replace the record of the given key with the given new record
First query the unique fields to make sure the replacement maintains uniqueness constraints.
repsert :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => Key a -> a -> m () Source #
Put the record in the database with the given key
If a record with the given key does not exist then a new record will be inserted.
repsertMany :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => [(Key a, a)] -> m () Source #
Put many entities into the database
For each item, if a record with the given key does not exist then a new record will be inserted.
Arguments
:: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) | |
=> [Filter a] | If you provide multiple values in the list, the conditions are ANDed together. |
-> [SelectOpt a] | |
-> m (Maybe (Entity a)) |
Get just the first record for the criteria
Arguments
:: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) | |
=> [Filter a] | If you provide multiple values in the list, the conditions are ANDed together. |
-> [SelectOpt a] | |
-> m [Key a] |
Get the Key
s of all records matching the given criteria
Arguments
:: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) | |
=> [Filter a] | If you provide multiple values in the list, the conditions are ANDed together. |
-> [SelectOpt a] | |
-> m [Entity a] | Entities corresponding to the filters and options provided |
transactionSave :: forall m. (HasCallStack, MonadSqlBackend m) => m () Source #
Commit the current transaction and begin a new one
transactionSaveWithIsolation Source #
Arguments
:: forall m. (HasCallStack, MonadSqlBackend m) | |
=> IsolationLevel | Isolation level |
-> m () |
Commit the current transaction and begin a new one
transactionUndo :: forall m. (HasCallStack, MonadSqlBackend m) => m () Source #
Roll back the current transaction and begin a new one
transactionUndoWithIsolation Source #
Arguments
:: forall m. (HasCallStack, MonadSqlBackend m) | |
=> IsolationLevel | Isolation level |
-> m () |
Roll back the current transaction and begin a new one
update :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => Key a -> [Update a] -> m () Source #
Update individual fields on a specific record
updateGet :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) => Key a -> [Update a] -> m a Source #
Update individual fields on a specific record, and retrieve the updated value from the database
This function will throw an exception if the given key is not found in the database.
Arguments
:: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) | |
=> [Filter a] | If you provide multiple values in the list, the conditions are ANDed together. |
-> [Update a] | |
-> m () |
Update individual fields on any record matching the given criteria
Arguments
:: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend) | |
=> [Filter a] | If you provide multiple values in the list, the conditions are ANDed together. |
-> [Update a] | |
-> m Int64 | The number of rows affected |
Update individual fields on any record matching the given criteria
Arguments
:: forall a m. (HasCallStack, MonadSqlBackend m, OnlyOneUniqueKey a, PersistEntityBackend a ~ SqlBackend, SafeToInsert a) | |
=> a | New record to insert |
-> [Update a] | Updates to perform if the record already exists |
-> m (Entity a) | The record in the database after the operation |
Update based on a uniqueness constraint or insert:
- Unsert the new record if it does not exist;
- If the record exists (matched via it's uniqueness constraint), then update the existing record with the parameters which is passed on as list to the function.
Arguments
:: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a, PersistEntityBackend a ~ SqlBackend, SafeToInsert a) | |
=> Unique a | Uniqueness constraint to find by |
-> a | New record to insert |
-> [Update a] | Updates to perform if the record already exists |
-> m (Entity a) | The record in the database after the operation |
Update based on a given uniqueness constraint or insert:
- Insert the new record if it does not exist;
- Update the existing record that matches the given uniqueness constraint.