import { Value } from "@convex-dev/common";

export type Cursor = string;

/**
 * @internal
 */
export interface PaginationResult {
  page: Value[];
  isDone: boolean;
  continueCursor: Cursor;
}

/**
 * @internal
 */
export interface PaginationOptions {
  /**
   * What is the maximum number of rows that should be returned to `paginate()`?
   */
  pageSize?: number;

  /**
   * What is the maximum number of rows that should be read from the database? This option
   * is different from `pageSize` in that it controls the number of rows entering a query's
   * pipeline, where `pageSize` controls the number of rows coming out. For example, a `filter`
   * may disqualify most of the rows coming in, so setting a low `pageSize` would not help
   * bound its execution time. Instead, set a low `maximumRowsRead` to efficiently paginate
   * through the filter.
   */
  maximumRowsRead?: number;
}
