select<T extends HasResultSet, R> method

SimpleSelectStatement<T, R> select<T extends HasResultSet, R>(
  1. ResultSetImplementation<T, R> table, {
  2. bool distinct = false,
})
inherited

Starts a query on the given table.

In drift, queries are commonly used as a builder by chaining calls on them using the .. syntax from Dart. For instance, to load the 10 oldest users with an 'S' in their name, you could use:

Future<List<User>> oldestUsers() {
  return (
    select(users)
      ..where((u) => u.name.like('%S%'))
      ..orderBy([(u) => OrderingTerm(
        expression: u.id,
        mode: OrderingMode.asc
      )])
      ..limit(10)
  ).get();
}

The distinct parameter (defaults to false) can be used to remove duplicate rows from the result set.

For more information on queries, see the documentation.

Implementation

SimpleSelectStatement<T, R> select<T extends HasResultSet, R>(
    ResultSetImplementation<T, R> table,
    {bool distinct = false}) {
  return SimpleSelectStatement<T, R>(this, table, distinct: distinct);
}