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

Method getEntityManager

packages/core/src/entity/Collection.ts:437–455  ·  view source on GitHub ↗
(items: Iterable<T> = [], required = true)

Source from the content-addressed store, hash-verified

435 }
436
437 private getEntityManager(items: Iterable<T> = [], required = true) {
438 const wrapped = helper(this.owner);
439 let em = wrapped.__em;
440
441 if (!em) {
442 for (const i of items) {
443 if (i && helper(i).__em) {
444 em = helper(i).__em;
445 break;
446 }
447 }
448 }
449
450 if (!em && required) {
451 throw ValidationError.entityNotManaged(this.owner);
452 }
453
454 return em;
455 }
456
457 /** The owning-side property this collection is mapped by (the inverse of `mappedBy`); `undefined` for the owning side of m:n. */
458 private get mappedByProp(): EntityProperty | undefined {

Callers 13

loadMethod · 0.95
loadCountMethod · 0.95
matchingMethod · 0.95
addMethod · 0.95
removeMethod · 0.95
initMethod · 0.95
cancelOrphanRemovalMethod · 0.95
getContextMethod · 0.45
getEntityManagerFunction · 0.45
CreateRequestContextFunction · 0.45
TransactionalFunction · 0.45
CreateRequestContextFunction · 0.45

Calls 2

helperFunction · 0.85
entityNotManagedMethod · 0.80

Tested by

no test coverage detected