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

Method nativeDelete

packages/core/src/EntityManager.ts:1992–2016  ·  view source on GitHub ↗

* Fires native delete query. Calling this has no side effects on the context (identity map).

(
    entityName: EntityName<Entity>,
    where: FilterQuery<NoInfer<Entity>>,
    options: DeleteOptions<Entity> = {},
  )

Source from the content-addressed store, hash-verified

1990 * Fires native delete query. Calling this has no side effects on the context (identity map).
1991 */
1992 async nativeDelete<Entity extends object>(
1993 entityName: EntityName<Entity>,
1994 where: FilterQuery<NoInfer<Entity>>,
1995 options: DeleteOptions<Entity> = {},
1996 ): Promise<number> {
1997 const em = this.getContext(false);
1998 em.prepareOptions(options);
1999
2000 await em.processUnionWhere(entityName, options, 'delete');
2001
2002 where = (await em.processWhere(
2003 entityName,
2004 where as FilterQuery<Entity>,
2005 options as FindOptions<Entity>,
2006 'delete',
2007 )) as typeof where;
2008 validateParams(where, 'delete condition');
2009 const res = await em.driver.nativeDelete(entityName, where, {
2010 ctx: em.#transactionContext,
2011 em,
2012 ...options,
2013 } as NativeDeleteOptions<Entity>);
2014
2015 return res.affectedRows;
2016 }
2017
2018 /**
2019 * Maps raw database result to an entity and merges it to this EntityManager.

Callers

nothing calls this directly

Calls 6

getContextMethod · 0.95
validateParamsFunction · 0.85
processUnionWhereMethod · 0.80
nativeDeleteMethod · 0.65
prepareOptionsMethod · 0.45
processWhereMethod · 0.45

Tested by

no test coverage detected