MCPcopy Create free account
hub / github.com/mikro-orm/mikro-orm / constructor

Method constructor

packages/core/src/utils/Cursor.ts:70–92  ·  view source on GitHub ↗
(
    readonly items: Loaded<Entity, Hint, Fields, Excludes>[],
    readonly totalCount: IncludeCount extends true ? number : undefined,
    options: FindByCursorOptions<Entity, Hint, Fields, Excludes, IncludeCount>,
    meta: EntityMetadata<Entity>,
  )

Source from the content-addressed store, hash-verified

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) {

Callers

nothing calls this directly

Calls 1

getDefinitionMethod · 0.80

Tested by

no test coverage detected