first method
Returns the first selected row, or throws QUERY.CARDINALITY if empty.
Fetches at most one root row. Use orderBy for a deterministic first row.
A selected SQL NULL is a row and is returned when R is nullable.
Implementation
Future<R> first({ExecutionOptions options = const ExecutionOptions()}) async {
final rows = await take(queryState.limit == 0 ? 0 : 1)
.get(options: options);
if (rows.isEmpty) {
throw const OrmException(
'QUERY.CARDINALITY',
'Expected a row, received none.',
);
}
return rows.first;
}