(
readonly items: Loaded<Entity, Hint, Fields, Excludes>[],
readonly totalCount: IncludeCount extends true ? number : undefined,
options: FindByCursorOptions<Entity, Hint, Fields, Excludes, IncludeCount>,
meta: EntityMetadata<Entity>,
)
| 68 | readonly #definition: (readonly [EntityKey<Entity>, QueryOrder])[]; |
| 69 | |
| 70 | constructor( |
| 71 | readonly items: Loaded<Entity, Hint, Fields, Excludes>[], |
| 72 | readonly totalCount: IncludeCount extends true ? number : undefined, |
| 73 | options: FindByCursorOptions<Entity, Hint, Fields, Excludes, IncludeCount>, |
| 74 | meta: EntityMetadata<Entity>, |
| 75 | ) { |
| 76 | const { first, last, before, after, orderBy, overfetch } = options; |
| 77 | const limit = first ?? last; |
| 78 | const isLast = !first && !!last; |
| 79 | const hasMorePages = !!overfetch && limit != null && items.length > limit; |
| 80 | this.hasPrevPage = isLast ? hasMorePages : !!after; |
| 81 | this.hasNextPage = isLast ? !!before : hasMorePages; |
| 82 | |
| 83 | if (hasMorePages) { |
| 84 | if (isLast) { |
| 85 | items.shift(); |
| 86 | } else { |
| 87 | items.pop(); |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | this.#definition = Cursor.getDefinition(meta, orderBy!); |
| 92 | } |
| 93 | |
| 94 | get startCursor(): string | null { |
| 95 | if (this.items.length === 0) { |
nothing calls this directly
no test coverage detected