insertAll method

Future<void> insertAll(
  1. Iterable<Insertable<Row>> rows, {
  2. InsertMode? mode,
  3. UpsertClause<Tbl, Row>? onConflict,
})

Atomically inserts all rows into the table.

The mode and onConflict clause can optionally control the behavior of an insert if an existing row conflicts with a new one. Unlike calling Batch.insertAll in a Batch directly, foreign keys are checked only after all inserts ran. In other words, the order in which the rows are in doesn't matter if there are foreign keys between them.

Implementation

Future<void> insertAll(Iterable<Insertable<Row>> rows,
    {InsertMode? mode, UpsertClause<Tbl, Row>? onConflict}) {
  return attachedDatabase.batch((b) {
    b.customStatement('pragma defer_foreign_keys = on;');
    b.insertAll(this, rows, mode: mode, onConflict: onConflict);
  });
}