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

Method mergeOrderBy

packages/core/src/utils/QueryHelper.ts:599–621  ·  view source on GitHub ↗

* Merges multiple orderBy sources with key-level deduplication (first-seen key wins). * RawQueryFragment symbol keys are never deduped (each is unique).

(...sources: (QueryOrderMap<T> | QueryOrderMap<T>[] | undefined)[])

Source from the content-addressed store, hash-verified

597 * RawQueryFragment symbol keys are never deduped (each is unique).
598 */
599 static mergeOrderBy<T>(...sources: (QueryOrderMap<T> | QueryOrderMap<T>[] | undefined)[]): QueryOrderMap<T>[] {
600 const result: QueryOrderMap<T>[] = [];
601 const seenKeys = new Set<string>();
602
603 for (const source of sources) {
604 if (source == null) {
605 continue;
606 }
607
608 for (const item of Utils.asArray(source)) {
609 for (const key of Utils.getObjectQueryKeys(item)) {
610 if (typeof key === 'symbol') {
611 result.push({ [key]: item[key as EntityKey] } as QueryOrderMap<T>);
612 } else if (!seenKeys.has(key)) {
613 seenKeys.add(key);
614 result.push({ [key]: item[key] } as QueryOrderMap<T>);
615 }
616 }
617 }
618 }
619
620 return result;
621 }
622}
623
624interface ProcessWhereOptions<T> {

Callers 6

buildToManyOrderByFunction · 0.80
findMethod · 0.80
matchingMethod · 0.80
initMethod · 0.80
populateManyMethod · 0.80
findChildrenMethod · 0.80

Calls 5

asArrayMethod · 0.80
getObjectQueryKeysMethod · 0.80
pushMethod · 0.80
addMethod · 0.80
hasMethod · 0.65

Tested by

no test coverage detected