Table of Contents

Namespace Tharga.MongoDB.Paging

Classes

CursorPage<T>

One page of items from a keyset-paginated query. FirstCursor / LastCursor are the boundary cursors for navigating one page back / forward. HasNext / HasPrevious let UIs disable navigation buttons. Total count is intentionally not included — call CountAsync(predicate) separately and cache it.

CursorPager<TEntity, TKey>

Grid-agnostic state helper that wraps GetPageAsync for grid components driven by (skip, pageSize). Encapsulates: the per-filter total-count cache, the previous page's first/last cursors, and the Skip→PagePosition decoder. Falls back to skip-based GetManyAsync for arbitrary page-number jumps and re-issues cursors via From<TEntity, TKey>(TEntity, Expression<Func<TEntity, object>>, bool) so subsequent prev/next stays on the keyset path. Built only on the public Layer 1 API — same access any consumer has, no privileged paths.

Structs

CursorToken

Opaque cursor identifying a boundary document in a keyset-paginated query. Carries the sort-field path, sort direction, the sort-field value at the boundary, and the document _id (used as a tiebreaker on non-unique sort fields). Round-trip via ToString() + Parse(string) for URL-safe storage.

PagePosition

Where in a keyset-paginated stream IRepositoryCollection<TEntity, TKey>'s GetPageAsync should resume from. Construct via the static factories (First, Last, After(CursorToken, int), Before(CursorToken, int)).