selectIDsByQuery<I extends Object> method

FutureOr<Iterable<I>> selectIDsByQuery<I extends Object>(
  1. String query, {
  2. Object? parameters,
  3. List? positionalParameters,
  4. Map<String, Object?>? namedParameters,
  5. Transaction? transaction,
  6. int? limit,
  7. int? offset,
  8. int? page,
  9. bool? orderByID,
  10. OrderDirection? orderDirection,
})

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, and, with a SQL database, also when limit is defined (which rows an unordered LIMIT returns is undefined). Pass false to opt out.
  • orderDirection: the OrderDirection of the ordering, OrderDirection.ascending by default. Ignored while the ordering is not active (see orderByID).

A query over a to-many relationship returns (and counts, and paginates) each entity once: with a SQL database, its JOINs are in a subquery of the matching IDs. Note that 2 conditions over the same to-many relationship (roles.type == "a" && roles.type == "b") are, on SQL, over the same joined row, and in memory each over any related entity.

Implementation

FutureOr<Iterable<I>> selectIDsByQuery<I extends Object>(
  String query, {
  Object? parameters,
  List? positionalParameters,
  Map<String, Object?>? namedParameters,
  Transaction? transaction,
  int? limit,
  int? offset,
  int? page,
  bool? orderByID,
  OrderDirection? orderDirection,
}) {
  var condition = _parseCache.parseQuery(query);

  return selectIDsBy(
    condition,
    parameters: parameters,
    positionalParameters: positionalParameters,
    namedParameters: namedParameters,
    transaction: transaction,
    limit: limit,
    offset: resolveSelectOffset(page: page, offset: offset, limit: limit),
    orderByID: orderByID,
    orderDirection: orderDirection,
  );
}