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

Method tryFlush

packages/core/src/EntityManager.ts:2432–2447  ·  view source on GitHub ↗

* @internal

(
    entityName: EntityName<Entity>,
    options: { flushMode?: FlushMode | AnyString },
  )

Source from the content-addressed store, hash-verified

2430 * @internal
2431 */
2432 async tryFlush<Entity extends object>(
2433 entityName: EntityName<Entity>,
2434 options: { flushMode?: FlushMode | AnyString },
2435 ): Promise<void> {
2436 const em = this.getContext();
2437 const flushMode = options.flushMode ?? em.#flushMode ?? em.config.get('flushMode');
2438 const meta = em.metadata.get(entityName);
2439
2440 if (flushMode === FlushMode.COMMIT) {
2441 return;
2442 }
2443
2444 if (flushMode === FlushMode.ALWAYS || em.getUnitOfWork().shouldAutoFlush(meta)) {
2445 await em.flush();
2446 }
2447 }
2448
2449 /**
2450 * Clears the EntityManager. All entities that are currently managed by this EntityManager become detached.

Callers 8

countByMethod · 0.80
countByMethod · 0.80
getResultListMethod · 0.80
findMethod · 0.80
streamMethod · 0.80
findAndCountMethod · 0.80
findOneMethod · 0.80
countMethod · 0.80

Calls 5

getContextMethod · 0.95
shouldAutoFlushMethod · 0.80
getUnitOfWorkMethod · 0.80
getMethod · 0.65
flushMethod · 0.45

Tested by

no test coverage detected