watchSingle method

  1. @override
Stream<T> watchSingle()

Creates an auto-updating stream of this statement, similar to However, it is assumed that the query will only emit one result, so instead of returning a Stream<List<T>>, this returns a Stream<T>. If, at any point, the query emits no or more than one rows, an error will be added to the stream instead.

Be aware that this operation won't put a limit clause on this statement, if that's needed you would have to do use SimpleSelectStatement.limit:

Future<TodoEntry> loadMostImportant() {
  return (select(todos)
   ..orderBy([(t) =>
      OrderingTerm(expression: t.priority, mode: OrderingMode.desc)])

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 where clause will only allow one row.


Stream<T> watchSingle() {
  return watch().transform(singleElements());