watchFirst method

  1. @override
Stream<T?>? watchFirst({
  1. DatumQuery? query,
  2. String? userId,
})
override

Watch the first entity matching a query, optionally sorted. Return null if the adapter does not support this feature.

Implementation

@override
Stream<T?>? watchFirst({DatumQuery? query, String? userId}) {
  return _watch(() async {
    final items = query != null ? await this.query(query, userId: userId) : await readAll(userId: userId);
    return items.isEmpty ? null : items.first;
  }, userId: userId);
}