single method

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

Executes the mutation and requires exactly one returned row.

Throws QUERY.CARDINALITY after execution if the result is empty or has multiple rows. Use a transaction if that failure must roll back the write.

Implementation

Future<R> single({
  ExecutionOptions options = const ExecutionOptions(),
}) async {
  final result = await get(options: options);
  if (result.length != 1) {
    throw OrmException(
      'QUERY.CARDINALITY',
      'Expected one returned row, received ${result.length}.',
    );
  }
  return result.single;
}