dropPageSentinel method

List<TRow> dropPageSentinel(
  1. List<TRow> fetched,
  2. int pageSize
)

Drops the extra row a page fetched to learn hasMore, before include.

Including the sentinel would load relations for a parent that is not on the page. Call this, then attachIncludes.

Implementation

List<TRow> dropPageSentinel(List<TRow> fetched, int pageSize) {
  if (pageSize <= 0) {
    throw ArgumentError.value(pageSize, 'pageSize', 'Must be positive.');
  }
  if (fetched.length <= pageSize) return fetched;
  return fetched.sublist(0, pageSize);
}