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

Function nativeDelete

packages/sql/src/AbstractSqlDriver.ts:1652–1674  ·  view source on GitHub ↗
(
    entityName: EntityName<T>,
    where: FilterQuery<T> | string | any,
    options: DeleteOptions<T> = {},
  )

Source from the content-addressed store, hash-verified

1650 }
1651
1652 async nativeDelete<T extends object>(
1653 entityName: EntityName<T>,
1654 where: FilterQuery<T> | string | any,
1655 options: DeleteOptions<T> = {},
1656 ): Promise<QueryResult<T>> {
1657 const meta = this.metadata.get(entityName);
1658 const pks = this.getPrimaryKeyFields(meta);
1659
1660 if (Utils.isPrimaryKey(where) && pks.length === 1) {
1661 where = { [pks[0]]: where };
1662 }
1663
1664 if (options.unionWhere?.length) {
1665 where = await this.applyUnionWhere(meta, where as ObjectQuery<T>, options, true);
1666 }
1667
1668 const qb = this.createQueryBuilder(entityName, options.ctx, 'write', false, options.loggerContext)
1669 .delete(where)
1670 .withSchema(this.getSchemaName(meta, options));
1671 qb.setAbortOptions(pickAbortOptions(options));
1672
1673 return this.rethrow(qb.execute('run', false));
1674 }
1675
1676 /**
1677 * Fast comparison for collection snapshots that are represented by PK arrays.

Callers

nothing calls this directly

Calls 10

pickAbortOptionsFunction · 0.85
isPrimaryKeyMethod · 0.80
setAbortOptionsMethod · 0.80
rethrowMethod · 0.80
getMethod · 0.65
withSchemaMethod · 0.65
deleteMethod · 0.65
getSchemaNameMethod · 0.65
executeMethod · 0.65
createQueryBuilderMethod · 0.45

Tested by

no test coverage detected