singleOrNull method
Executes the mutation and accepts zero or one returned row.
Throws QUERY.CARDINALITY after execution for multiple rows. Use a
transaction if that failure must roll back the write.
Implementation
Future<R?> singleOrNull({
ExecutionOptions options = const ExecutionOptions(),
}) async {
final rows = await get(options: options);
if (rows.length > 1) {
throw OrmException(
'QUERY.CARDINALITY',
'Expected at most one returned row, received ${rows.length}.',
);
}
return rows.firstOrNull;
}