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

Method populateScalar

packages/core/src/entity/EntityLoader.ts:358–386  ·  view source on GitHub ↗
(
    meta: EntityMetadata<Entity>,
    filtered: Entity[],
    options: Required<EntityLoaderOptions<Entity>>,
  )

Source from the content-addressed store, hash-verified

356 }
357
358 private async populateScalar<Entity extends object>(
359 meta: EntityMetadata<Entity>,
360 filtered: Entity[],
361 options: Required<EntityLoaderOptions<Entity>>,
362 ) {
363 const pk = Utils.getPrimaryKeyHash(meta.primaryKeys) as FilterKey<Entity>;
364 const ids = Utils.unique(filtered.map(e => Utils.getPrimaryKeyValues(e, meta, true)));
365 const where = this.mergePrimaryCondition<Entity>(
366 ids as Entity[],
367 pk,
368 options,
369 meta,
370 this.#metadata,
371 this.#driver.getPlatform(),
372 );
373 const { filters, convertCustomTypes, lockMode, strategy, populateWhere, connectionType, logging, fields } = options;
374
375 await this.#em.find(meta.class, where as any, {
376 filters,
377 convertCustomTypes,
378 lockMode,
379 strategy,
380 populateWhere,
381 connectionType,
382 logging,
383 fields: fields as never[],
384 populate: [],
385 });
386 }
387
388 private async populatePolymorphic<Entity extends object>(
389 entities: Entity[],

Callers 3

populateMethod · 0.95
populateManyMethod · 0.95
populatePolymorphicMethod · 0.95

Calls 7

mergePrimaryConditionMethod · 0.95
getPrimaryKeyHashMethod · 0.80
getPrimaryKeyValuesMethod · 0.80
uniqueMethod · 0.65
getPlatformMethod · 0.65
findMethod · 0.65
mapMethod · 0.45

Tested by

no test coverage detected