Hoogle Search

Within LTS Haskell 24.56 (ghc-9.10.3)

Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.

  1. insertEntityMany :: forall record (m :: Type -> Type) . (PersistStoreWrite backend, MonadIO m, PersistRecordBackend record backend) => [Entity record] -> ReaderT backend m ()

    persistent Database.Persist.Class.PersistStore

    Same as insertMany_, but takes an Entity instead of just a record. Useful when migrating data from one entity to another and want to preserve ids. The MongoDB, PostgreSQL, SQLite and MySQL backends insert all records in one database query.

    Example usage

    With schema-1 and dataset-1,
    insertUserEntityMany :: MonadIO m => ReaderT SqlBackend m ()
    insertUserEntityMany = insertEntityMany [SnakeEntity, EvaEntity]
    
    The above query when applied on dataset-1, will produce this:
    +-----+------+-----+
    |id   |name  |age  |
    +-----+------+-----+
    |1    |SPJ   |40   |
    +-----+------+-----+
    |2    |Simon |41   |
    +-----+------+-----+
    |3    |Snake |38   |
    +-----+------+-----+
    |4    |Eva   |38   |
    +-----+------+-----+
    

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

    persistent Database.Persist.Class.PersistStore

    Create multiple records in the database and return their Keys. If you don't need the inserted Keys, use insertMany_. The MongoDB and PostgreSQL backends insert all records and retrieve their keys in one database query. The SQLite and MySQL backends use the slow, default implementation of mapM insert.

    Example usage

    with schema-1 and dataset-1,
    insertUsers :: MonadIO m => ReaderT SqlBackend m [Key User]
    insertUsers = insertMany [User "John" 30, User "Nick" 32, User "Jane" 20]
    
    userIds <- insertUsers
    
    The above query when applied on dataset-1, will produce this:
    +-----+------+-----+
    |id   |name  |age  |
    +-----+------+-----+
    |1    |SPJ   |40   |
    +-----+------+-----+
    |2    |Simon |41   |
    +-----+------+-----+
    |3    |John  |30   |
    +-----+------+-----+
    |4    |Nick  |32   |
    +-----+------+-----+
    |5    |Jane  |20   |
    +-----+------+-----+
    

  3. insertMany_ :: forall record (m :: Type -> Type) . (PersistStoreWrite backend, MonadIO m, PersistRecordBackend record backend, SafeToInsert record) => [record] -> ReaderT backend m ()

    persistent Database.Persist.Class.PersistStore

    Same as insertMany, but doesn't return any Keys. The MongoDB, PostgreSQL, SQLite and MySQL backends insert all records in one database query.

    Example usage

    With schema-1 and dataset-1,
    insertUsers_ :: MonadIO m => ReaderT SqlBackend m ()
    insertUsers_ = insertMany_ [User "John" 30, User "Nick" 32, User "Jane" 20]
    
    The above query when applied on dataset-1, will produce this:
    +-----+------+-----+
    |id   |name  |age  |
    +-----+------+-----+
    |1    |SPJ   |40   |
    +-----+------+-----+
    |2    |Simon |41   |
    +-----+------+-----+
    |3    |John  |30   |
    +-----+------+-----+
    |4    |Nick  |32   |
    +-----+------+-----+
    |5    |Jane  |20   |
    +-----+------+-----+
    

  4. repsertMany :: forall record (m :: Type -> Type) . (PersistStoreWrite backend, MonadIO m, PersistRecordBackend record backend) => [(Key record, record)] -> ReaderT backend m ()

    persistent Database.Persist.Class.PersistStore

    Put many entities into the database. Batch version of repsert for SQL backends. Useful when migrating data from one entity to another and want to preserve ids.

    Example usage

    With schema-1 and dataset-1,
    repsertManyUsers :: MonadIO m =>ReaderT SqlBackend m ()
    repsertManyusers = repsertMany [(simonId, User "Philip" 20), (unknownId999, User "Mr. X" 999)]
    
    The above query when applied on dataset-1, will produce this:
    +-----+----------------+---------+
    |id   |name            |age      |
    +-----+----------------+---------+
    |1    |SPJ             |40       |
    +-----+----------------+---------+
    |2    |Simon -> Philip |41 -> 20 |
    +-----+----------------+---------+
    |999  |Mr. X           |999      |
    +-----+----------------+---------+
    

  5. defaultPutMany :: forall record backend (m :: Type -> Type) . (PersistEntityBackend record ~ BaseBackend backend, PersistEntity record, MonadIO m, PersistStoreWrite backend, PersistUniqueRead backend, SafeToInsert record) => [record] -> ReaderT backend m ()

    persistent Database.Persist.Class.PersistUnique

    The slow but generic putMany implementation for any PersistUniqueRead. * Lookup corresponding entities (if any) for each record using getByValue * For pre-existing records, issue a replace for each old key and new record * For new records, issue a bulk insertMany_

  6. putMany :: forall record (m :: Type -> Type) . (PersistUniqueWrite backend, MonadIO m, PersistRecordBackend record backend, SafeToInsert record) => [record] -> ReaderT backend m ()

    persistent Database.Persist.Class.PersistUnique

    Put many records into db

    • insert new records that do not exist (or violate any unique constraints)
    • replace existing records (matching any unique constraint)

  7. ISRManyKeys :: Text -> [PersistValue] -> InsertSqlResult

    persistent Database.Persist.Sql

    No documentation available.

  8. ISRManyKeys :: Text -> [PersistValue] -> InsertSqlResult

    persistent Database.Persist.Sql.Types.Internal

    No documentation available.

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

    persistent Database.Persist.Sql.Types.Internal

    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.

  10. connPutManySql :: SqlBackend -> Maybe (EntityDef -> Int -> Text)

    persistent Database.Persist.Sql.Types.Internal

    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.

Page 121 of many | Previous | Next