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

Method getCloneableProps

packages/sql/src/query/QueryBuilder.ts:3519–3538  ·  view source on GitHub ↗

Returns properties that are safe to clone (persistable, non-PK, non-generated).

(meta: EntityMetadata)

Source from the content-addressed store, hash-verified

3517
3518 /** Returns properties that are safe to clone (persistable, non-PK, non-generated). */
3519 private getCloneableProps(meta: EntityMetadata): EntityProperty[] {
3520 return meta.props.filter(prop => {
3521 if (prop.persist === false) {
3522 return false;
3523 }
3524 if (prop.primary) {
3525 return false;
3526 }
3527 if (!prop.fieldNames?.length) {
3528 return false;
3529 }
3530 if ([ReferenceKind.ONE_TO_MANY, ReferenceKind.MANY_TO_MANY].includes(prop.kind)) {
3531 return false;
3532 }
3533 if (prop.kind === ReferenceKind.EMBEDDED && !prop.object) {
3534 return false;
3535 }
3536 return true;
3537 });
3538 }
3539
3540 private applyDiscriminatorCondition(): void {
3541 const meta = this.mainAlias.meta;

Callers 3

nativeCloneSimpleFunction · 0.80
nativeCloneTPTFunction · 0.80

Calls 1

filterMethod · 0.80

Tested by

no test coverage detected