first method

Future<R> first({
  1. ExecutionOptions options = const ExecutionOptions(),
})

Executes the mutation and returns its first row, rejecting an empty result.

The mutation still affects all matching rows. Cardinality is checked after execution; a returned SQL NULL is a row when R is nullable.

Implementation

Future<R> first({ExecutionOptions options = const ExecutionOptions()}) async {
  final rows = await get(options: options);
  if (rows.isEmpty) {
    throw const OrmException(
      'QUERY.CARDINALITY',
      'Expected a returned row, received none.',
    );
  }
  return rows.first;
}