Batch class final

Contains operations to run queries in a batched mode.

Inside a batch, a set of SQL statements is collected and then run at once. Conceptually, batches are similar to a transaction (and they will use transactions internally). Additionally, batches are very efficient when the same SQL statement is executed with different parameters. Outside of a batch, a new statement would be parsed and prepared for each execution. With batches, statements are only prepared once and then run with the parameters needed.

This makes batches particularly suitable for bulk updates.

Properties

database → DatabaseConnectionUser
The database on which the batch will run when completed.
final
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

addStatement(SqlStatement stmt) → BatchedStatement
Adds an SqlStatement to execute in this batch.
customStatement(String sql, {List<Variable<Object>> args = const [], Iterable<TableUpdate> updates = const {}}) → BatchedStatement
Executes the custom sql statement with variables instantiated to args.
delete<Row extends Object, RS extends GeneratedTable<Row, RS>>(GeneratedTable<Row, RS> table, Insertable<Row> row) → BatchedStatement
Deletes row from the table when this batch is executed.
deleteAll<Row extends Object, RS extends GeneratedTable<Row, RS>>(GeneratedTable<Row, RS> table) → BatchedStatement
Deletes ALL rows from table.
deleteWhere<Row extends Object, RS extends GeneratedTable<Row, RS>>(GeneratedTable<Row, RS> table, Expression<bool> filter(RS tbl)) → BatchedStatement
Deletes all rows from table matching the provided filter.
insert<Row extends Object, RS extends GeneratedTable<Row, RS>>(GeneratedTable<Row, RS> table, Insertable<Row> row, {UpsertClause<Row, RS>? onConflict}) → BatchedStatement
Inserts a row constructed from the fields in row.
insertAll<Row extends Object, RS extends GeneratedTable<Row, RS>>(GeneratedTable<Row, RS> table, Iterable<Insertable<Row>> rows, {UpsertClause<Row, RS>? onConflict}) → void
Inserts all rows into the table.
insertAllOnConflictUpdate<Row extends Object, RS extends GeneratedTable<Row, RS>>(GeneratedTable<Row, RS> table, Iterable<Insertable<Row>> rows) → void
Equivalent of InsertStatement.insertOnConflictUpdate for multiple rows that will be inserted in this batch.
insertFromSelect<Row extends Object, RS extends GeneratedTable<Row, RS>>(GeneratedTable<Row, RS> table, BaseSelectStatement<BaseSelectStatement, dynamic> select, {required Map<TableColumn<Object>, Expression<Object>> columns, UpsertClause<Row, RS>? onConflict}) → BatchedStatement
Inserts rows from the select statement.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
replace<Row extends Object, RS extends GeneratedTable<Row, RS>>(GeneratedTable<Row, RS> table, Insertable<Row> row) → BatchedStatement
Replaces the row from the table with the updated values. The row in the table with the same primary key will be replaced.
replaceAll<Row extends Object, RS extends GeneratedTable<Row, RS>>(GeneratedTable<Row, RS> table, Iterable<Insertable<Row>> rows) → void
Helper that calls replace for all rows.
toString() → String
A string representation of this object.
inherited
update<Row extends Object, RS extends GeneratedTable<Row, RS>>(GeneratedTable<Row, RS> table, Insertable<Row> row, {Expression<bool> where(RS table)?}) → BatchedStatement
Writes all present columns from the row into all rows in the table that match the where clause.

Operators

operator ==(Object other) → bool
The equality operator.
inherited