paginateByQuery method

  1. @override
EntityPagination<O> paginateByQuery(
  1. String query, {
  2. Object? parameters,
  3. List? positionalParameters,
  4. Map<String, Object?>? namedParameters,
  5. required int limit,
  6. bool? orderByID,
  7. OrderDirection? orderDirection,
  8. Transaction? transaction,
  9. EntityResolutionRules? resolutionRules,
  10. EntityPaginationListener<O>? onEvent,
})
override

Returns an EntityPagination over this select, loading nothing yet: pages are fetched only when asked for. See EntityPagination.

  • limit: the page size. Required, and must be > 0.

  • orderByID: defaults to true. A paginated read is only meaningful over a stable order, so unlike the select* methods this is on by default instead of being implied by an offset.

  • orderDirection: the OrderDirection of the ordering.

  • onEvent: an optional hook notified of what is being fetched. See EntityPaginationEvent.

  • resolutionRules: applied to every loaded page.

Implementation

@override
EntityPagination<O> paginateByQuery(
  String query, {
  Object? parameters,
  List? positionalParameters,
  Map<String, Object?>? namedParameters,
  required int limit,
  bool? orderByID,
  OrderDirection? orderDirection,
  Transaction? transaction,
  EntityResolutionRules? resolutionRules,
  EntityPaginationListener<O>? onEvent,
}) => EntityPagination<O>(
  limit: limit,
  onEvent: onEvent,
  query: query,
  pageLoader: (page, limit) => selectByQuery(
    query,
    parameters: parameters,
    positionalParameters: positionalParameters,
    namedParameters: namedParameters,
    transaction: transaction,
    limit: limit,
    page: page,
    orderByID: orderByID ?? true,
    orderDirection: orderDirection,
    resolutionRules: resolutionRules,
  ).resolveMapped((os) => os.toList()),
);