loadAllEntriesByPaging method

Future<DataPageQueryResult<T>> loadAllEntriesByPaging({
  1. required DataPageQuery<T> pageQuery,
  2. ConditionQuery where(
    1. T model
    )?,
  3. List<FieldOrder> orderBy(
    1. T model
    )?,
  4. List<FieldWithValue> desiredFields(
    1. T model
    )?,
})

Make query with pagination.

Implementation

Future<DataPageQueryResult<T>> loadAllEntriesByPaging(
    {required DataPageQuery<T> pageQuery,
    ConditionQuery Function(T model)? where,
    List<FieldOrder> Function(T model)? orderBy,
    List<FieldWithValue> Function(T model)? desiredFields}) async {
  int count = await countEntries(where: where);
  return DataPageQueryResult<T>(
      count,
      await select(
          limit: pageQuery.resultsPerPage,
          offset: (pageQuery.page - 1) * pageQuery.resultsPerPage,
          where: where,
          orderBy: orderBy,
          desiredFields: desiredFields),
      pageQuery.page,
      pageQuery.resultsPerPage);
}