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

Method getPrimaryKeyCond

packages/core/src/utils/Utils.ts:590–601  ·  view source on GitHub ↗
(entity: T, primaryKeys: EntityKey<T>[])

Source from the content-addressed store, hash-verified

588 }
589
590 static getPrimaryKeyCond<T>(entity: T, primaryKeys: EntityKey<T>[]): Record<string, Primary<T>> | null {
591 const cond = primaryKeys.reduce((o, pk) => {
592 o[pk] = Utils.extractPK(entity[pk]);
593 return o;
594 }, {} as any);
595
596 if (Object.values(cond).some(v => v === null)) {
597 return null;
598 }
599
600 return cond;
601 }
602
603 /**
604 * Maps nested FKs from `[1, 2, 3]` to `[1, [2, 3]]`.

Callers 6

nativeInsertFunction · 0.80
nativeInsertManyFunction · 0.80
lockPessimisticFunction · 0.80
nativeInsertManyMethod · 0.80
checkOptimisticLocksMethod · 0.80
Utils.win.test.tsFile · 0.80

Calls 3

reduceMethod · 0.80
extractPKMethod · 0.80
valuesMethod · 0.45

Tested by

no test coverage detected