customWriteReturning method

Future<List<QueryRow>> customWriteReturning(
  1. String query, {
  2. List<Variable<Object>> variables = const [],
  3. Set<TableInfo<Table, dynamic>>? updates,
  4. UpdateKind? updateKind,

Runs a INSERT, UPDATE or DELETE statement returning rows.

You can use the updates parameter so that drift knows which tables are affected by your query. All select streams that depend on a table specified there will then update their data. For more accurate results, you can also set the updateKind parameter. This is optional, but can improve the accuracy of query updates, especially when using triggers.


Future<List<QueryRow>> customWriteReturning(
  String query, {
  List<Variable> variables = const [],
  Set<TableInfo>? updates,
  UpdateKind? updateKind,
}) {
  return _customWrite(query, variables, updates, updateKind,
      (executor, sql, vars) async {
    final rows = await executor.runSelect(sql, vars);
    return [for (final row in rows) QueryRow(row, attachedDatabase)];