doSelectAll<R> method

  1. @override
FutureOr<List<R>> doSelectAll<R>(
  1. TransactionOperation op,
  2. String entityName,
  3. String table, {
  4. int? limit,
  5. int? offset,
  6. bool? orderByID,
  7. OrderDirection? orderDirection,
  8. PreFinishDBOperation<Iterable<Map<String, dynamic>>, List<R>>? preFinish,
})
override

Ordering and pagination:

  • limit: the maximum number of returned entities. Also the page size of page.
  • offset: the return offset, for pagination.
  • page: the 1-based page to return, an ergonomic alternative to offset: it resolves to (page - 1) * limit. Requires a positive limit, and can't be combined with offset. See resolveSelectOffset.
  • orderByID: if true the result is ordered by the table ID column, automatically resolved from the table scheme (TableScheme.idFieldName) or from EntityHandler.idFieldName. Defaults to true when offset is defined, since a paginated select needs a stable order to be correct. Pass false to opt out.
  • orderDirection: the OrderDirection of the ordering, OrderDirection.ascending by default. Ignored while the ordering is not active (see orderByID).

Note that a query over a to-many relationship generates a JOIN without a DISTINCT, so it can return the same entity more than once. Paginating such a query is best-effort.

Implementation

@override
FutureOr<List<R>> doSelectAll<R>(
  TransactionOperation op,
  String entityName,
  String table, {
  int? limit,
  int? offset,
  bool? orderByID,
  OrderDirection? orderDirection,
  PreFinishDBOperation<Iterable<Map<String, dynamic>>, List<R>>? preFinish,
}) {
  return generateSelectSQL(
    op.transaction,
    entityName,
    table,
    ConditionANY(),
    limit: limit,
    offset: offset,
    orderByID: orderByID,
    orderDirection: orderDirection,
  ).resolveMapped((sql) {
    return selectSQL(
      op,
      entityName,
      table,
      sql,
    ).resolveMapped((r) => _finishSQLOperation(sql, op, r, preFinish));
  });
}