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

Method getDefinition

packages/core/src/utils/Cursor.ts:204–235  ·  view source on GitHub ↗
(
    meta: EntityMetadata<Entity>,
    orderBy: OrderDefinition<Entity>,
  )

Source from the content-addressed store, hash-verified

202 }
203
204 static getDefinition<Entity extends object>(
205 meta: EntityMetadata<Entity>,
206 orderBy: OrderDefinition<Entity>,
207 ): [EntityKey, QueryOrder][] {
208 return Utils.asArray(orderBy).flatMap(order => {
209 const ret: [EntityKey, QueryOrder][] = [];
210
211 for (const key of Utils.getObjectQueryKeys(order)) {
212 if (Raw.isKnownFragmentSymbol(key)) {
213 ret.push([key as EntityKey, order[key as unknown as EntityKey] as QueryOrder]);
214 continue;
215 }
216
217 const prop = meta.properties[key];
218
219 /* v8 ignore next */
220 if (
221 !prop ||
222 !(
223 [ReferenceKind.SCALAR, ReferenceKind.EMBEDDED, ReferenceKind.MANY_TO_ONE].includes(prop.kind) ||
224 (prop.kind === ReferenceKind.ONE_TO_ONE && prop.owner)
225 )
226 ) {
227 continue;
228 }
229
230 ret.push([prop.name as EntityKey, order[prop.name] as QueryOrder]);
231 }
232
233 return ret;
234 });
235 }
236
237 /** @ignore */
238 /* v8 ignore next */

Callers 3

forMethod · 0.95
constructorMethod · 0.80
processCursorOptionsFunction · 0.80

Calls 4

asArrayMethod · 0.80
getObjectQueryKeysMethod · 0.80
isKnownFragmentSymbolMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected