batchInsert

context(context: QueryExecutor)
abstract suspend fun batchInsert(entities: Iterable<T>): DbResult<Long>(source)

Inserts multiple entities into the data source using the specified driver context.

All the entities are written with a single multi-row INSERT. The inserted rows are not read back: values generated by the database (e.g. auto-incremented ids) are not returned. The operation fails with SQLError.Code.RowMismatch when the number of affected rows differs from the number of entities.

Return

A DbResult containing the number of inserted rows (equal to the number of entities), or an error if the operation fails.

Parameters

entities

The collection of entities of type T to be inserted into the data source.