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

Function applyPopulateHints

packages/core/src/entity/utils.ts:123–140  ·  view source on GitHub ↗
(
  populate: PopulateOptions<Entity>[],
  hints: Record<string, PopulateHintOptions>,
)

Source from the content-addressed store, hash-verified

121 * @internal
122 */
123export function applyPopulateHints<Entity>(
124 populate: PopulateOptions<Entity>[],
125 hints: Record<string, PopulateHintOptions>,
126): void {
127 for (const [path, hint] of Object.entries(hints)) {
128 const entry = findPopulateEntry(populate, path.split('.'));
129
130 if (!entry) {
131 continue;
132 }
133
134 for (const key of Object.keys(hint) as (keyof PopulateHintOptions)[]) {
135 if (hint[key] != null) {
136 (entry as Record<string, unknown>)[key] = hint[key];
137 }
138 }
139 }
140}

Callers 1

preparePopulateMethod · 0.85

Calls 3

findPopulateEntryFunction · 0.85
entriesMethod · 0.80
keysMethod · 0.45

Tested by

no test coverage detected