customInsert method

Future<int> customInsert(
  1. String query, {
  2. List<Variable<Object>> variables = const [],
  3. Set<SchemaEntityWithResultSet<Object, ResultSet<Object, dynamic>>>? updates,
})

Executes a custom insert statement and returns the last inserted rowid.

You can tell drift which tables your query is going to affect by using the updates parameter. Query-streams running on any of these tables will then be re-run.

Implementation

Future<int> customInsert(
  String query, {
  List<Variable> variables = const [],
  Set<SchemaEntityWithResultSet>? updates,
}) async {
  final result = await _customWrite(
    query,
    variables,
    updates,
    UpdateKind.insert,
    false,
  );
  return result.lastInsertRowId ?? 0;
}