getSingle method

  1. @override
Future<$ActiveDataclass> getSingle({
  1. bool distinct = true,
})
override

Executes this statement, like get, but only returns one value. If the query returns no or too many rows, the returned future will complete with an error.

Be aware that this operation won't put a limit clause on this statement, if that's needed you would have to do use limit: You should only use this method if you know the query won't have more than one row, for instance because you used limit(1) or you know the filters you've applied will only match one row.

See also: getSingleOrNull, which returns null instead of throwing if the query completes with no rows.

The distinct parameter (enabled by default) controls whether to generate a SELECT DISTINCT query, removing duplicates from the result.

Implementation

@override
Future<$ActiveDataclass> getSingle({bool distinct = true}) async =>
    (await get(distinct: distinct)).single;