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

Function nativeCloneSimple

packages/sql/src/AbstractSqlDriver.ts:982–1017  ·  view source on GitHub ↗
(
    meta: EntityMetadata<T>,
    where: FilterQuery<T>,
    overrides?: EntityData<T>,
    options: NativeInsertUpdateOptions<T> = {},
  )

Source from the content-addressed store, hash-verified

980 }
981
982 private async nativeCloneSimple<T extends object>(
983 meta: EntityMetadata<T>,
984 where: FilterQuery<T>,
985 overrides?: EntityData<T>,
986 options: NativeInsertUpdateOptions<T> = {},
987 ): Promise<QueryResult<T>> {
988 const props = this.getCloneableProps(meta);
989 const mappedOverrides = this.mapCloneOverrides(overrides, meta, options);
990 const { selectFields, insertColumns } = this.buildCloneFields(props, mappedOverrides, meta);
991
992 const abort = pickAbortOptions(options);
993 const selectQb = this.createQueryBuilder<T>(
994 meta.class,
995 options.ctx,
996 'read',
997 options.convertCustomTypes,
998 options.loggerContext,
999 ).withSchema(this.getSchemaName(meta, options));
1000 selectQb.select(selectFields as any).where(where as any);
1001 selectQb.setAbortOptions(abort);
1002
1003 const insertQb = this.createQueryBuilder<T>(
1004 meta.class,
1005 options.ctx,
1006 'write',
1007 options.convertCustomTypes,
1008 options.loggerContext,
1009 ).withSchema(this.getSchemaName(meta, options));
1010 insertQb.setAbortOptions(abort);
1011
1012 return this.rethrow(
1013 (insertQb as AnyQueryBuilder<T>)
1014 .insertFrom(selectQb as AnyQueryBuilder<T>, { columns: insertColumns as any })
1015 .execute('run', false),
1016 );
1017 }
1018
1019 private async nativeCloneTPT<T extends object>(
1020 leafMeta: EntityMetadata<T>,

Callers

nothing calls this directly

Calls 11

pickAbortOptionsFunction · 0.85
getCloneablePropsMethod · 0.80
setAbortOptionsMethod · 0.80
rethrowMethod · 0.80
insertFromMethod · 0.80
withSchemaMethod · 0.65
getSchemaNameMethod · 0.65
whereMethod · 0.65
selectMethod · 0.65
executeMethod · 0.65
createQueryBuilderMethod · 0.45

Tested by

no test coverage detected