join method

JoinedSelectStatement<HasResultSet, dynamic> join(
  1. List<Join<HasResultSet, dynamic>> joins
)

Creates a select statement that operates on more than one table by applying the given joins.

Example from the todolist example which will load the category for each item:

final results = await select(todos).join([
  leftOuterJoin(categories, categories.id.equalsExp(todos.category))
]).get();

return results.map((row) {
  final entry = row.readTable(todos);
  final category = row.readTable(categories);
  return EntryWithCategory(entry, category);
}).toList();

See also:

Implementation

JoinedSelectStatement join(List<Join> joins) {
  final statement = JoinedSelectStatement(database, table, joins, distinct);

  if (whereExpr != null) {
    statement.where(whereExpr!.predicate);
  }
  if (orderByExpr != null) {
    statement.orderBy(orderByExpr!.terms);
  }
  if (limitExpr != null) {
    statement.limitExpr = limitExpr;
  }

  return statement;
}