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

Method findEntity

packages/core/src/entity/EntityFactory.ts:563–581  ·  view source on GitHub ↗
(
    data: EntityData<T>,
    meta: EntityMetadata<T>,
    options: FactoryOptions,
  )

Source from the content-addressed store, hash-verified

561 }
562
563 private findEntity<T extends object>(
564 data: EntityData<T>,
565 meta: EntityMetadata<T>,
566 options: FactoryOptions,
567 ): T | undefined {
568 const schema = this.#driver.getSchemaName(meta, options);
569
570 if (meta.simplePK) {
571 return this.unitOfWork.getById<T>(meta.class, data[meta.primaryKeys[0]] as Primary<T>, schema);
572 }
573
574 if (!Array.isArray(data) && meta.primaryKeys.some(pk => data[pk] == null)) {
575 return undefined;
576 }
577
578 const pks = Utils.getOrderedPrimaryKeys<T>(data as Dictionary, meta, this.#platform, options.convertCustomTypes);
579
580 return this.unitOfWork.getById<T>(meta.class, pks, schema);
581 }
582
583 private processDiscriminatorColumn<T extends object>(
584 meta: EntityMetadata<T>,

Callers 1

createMethod · 0.95

Calls 3

getOrderedPrimaryKeysMethod · 0.80
getSchemaNameMethod · 0.65
getByIdMethod · 0.45

Tested by

no test coverage detected