insert<T extends Table, D> method
void
insert<T extends Table, D>(
- TableInfo<
T, D> table, - Insertable<
D> row, { - InsertMode? mode,
- UpsertClause<
T, D> ? onConflict,
Inserts a row constructed from the fields in row.
All fields in the entity that don't have a default value or auto-increment must be set and non-null. Otherwise, an InvalidDataException will be thrown.
By default, an exception will be thrown if another row with the same
primary key already exists. This behavior can be overridden with mode,
for instance by using InsertMode.replace or InsertMode.insertOrIgnore.
onConflict can be used to create an upsert clause for engines that
support it. For details and examples, see InsertStatement.insert.
See also:
- InsertStatement.insert, which would be used outside a Batch.
Implementation
void insert<T extends Table, D>(TableInfo<T, D> table, Insertable<D> row,
{InsertMode? mode, UpsertClause<T, D>? onConflict}) {
_addUpdate(table, UpdateKind.insert);
final actualMode = mode ?? InsertMode.insert;
final context = InsertStatement<T, D>(_user, table)
.createContext(row, actualMode, onConflict: onConflict);
_addContext(context);
}