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

Method for

packages/core/src/utils/Cursor.ts:173–188  ·  view source on GitHub ↗

* Computes the cursor value for given entity and order definition.

(
    meta: EntityMetadata<Entity>,
    entity: FilterObject<Entity>,
    orderBy: OrderDefinition<Entity>,
  )

Source from the content-addressed store, hash-verified

171 * Computes the cursor value for given entity and order definition.
172 */
173 static for<Entity extends object>(
174 meta: EntityMetadata<Entity>,
175 entity: FilterObject<Entity>,
176 orderBy: OrderDefinition<Entity>,
177 ): string {
178 const definition = this.getDefinition(meta, orderBy);
179 return Cursor.encode(
180 definition.map(([key]) => {
181 const value = entity[key];
182 if (value === undefined) {
183 throw CursorError.missingValue(meta.className, key as string);
184 }
185 return value;
186 }),
187 );
188 }
189
190 static encode(value: unknown[]): string {
191 return Buffer.from(JSON.stringify(value)).toString('base64url');

Calls 4

getDefinitionMethod · 0.95
encodeMethod · 0.80
missingValueMethod · 0.80
mapMethod · 0.45

Tested by

no test coverage detected