mapToOneOrDefault<T> method

Stream<T> mapToOneOrDefault<T>(
  1. T rowMapper(
    1. JSON row
    ),
  2. T defaultValue
)

Given a function mapping the current row to T, transform each emitted Query which returns a single row to T.

It is an StateError for a query to pass through this operator with more than 1 row in its result set. Use LIMIT 1 on the underlying SQL query to prevent this. Emits defaultValue when result sets has 0 rows

Implementation

Stream<T> mapToOneOrDefault<T>(
        T Function(JSON row) rowMapper, T defaultValue) =>
    _queryToOneStreamTransformer(this, rowMapper, _Wrapper(defaultValue));