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

Method check

packages/core/src/entity/Collection.ts:543–562  ·  view source on GitHub ↗
(item: AnyEntity)

Source from the content-addressed store, hash-verified

541 }
542
543 const check = (item: AnyEntity) => {
544 if (!item) {
545 return false;
546 }
547
548 if (!Utils.isEntity(item)) {
549 throw ValidationError.notEntity(this.owner, this.property, item);
550 }
551
552 // currently we allow persisting to inverse sides only in SQL drivers
553 if (this.property.pivotTable || !this.property.mappedBy) {
554 return false;
555 }
556
557 if (helper(item).__initialized) {
558 return false;
559 }
560
561 return !item[this.property.mappedBy] && this.property.kind === ReferenceKind.MANY_TO_MANY;
562 };
563
564 // throw if we are modifying inverse side of M:N collection when owning side is initialized (would be ignored when persisting)
565 if (items.some(item => check(item))) {

Callers

nothing calls this directly

Calls 3

helperFunction · 0.85
notEntityMethod · 0.80
isEntityMethod · 0.45

Tested by

no test coverage detected