where method

void where(
  1. Expression<bool> filter(
    1. T tbl

Makes this statement only include rows that match the filter.

For instance, if you have a table users with an id column, you could select a user with a specific id by using

(select(users)..where((u) => u.id.equals(42))).watchSingle()

Please note that this where call is different to Iterable.where and Stream.where in the sense that filter will NOT be called for each row. Instead, it will only be called once (with the underlying table as parameter). The result Expression will be written as a SQL string and sent to the underlying database engine. The filtering does not happen in Dart. If a where condition has already been set before, the resulting filter will be the conjunction of both calls.

For more information, see:


void where(Expression<bool> Function(T tbl) filter) {
  final predicate = filter(table.asDslTable);

  if (whereExpr == null) {
    whereExpr = Where(predicate);
  } else {
    whereExpr = Where(whereExpr!.predicate & predicate);