@mikro-orm/core 6.5.6-dev.9 → 6.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/EntityManager.d.ts +23 -0
- package/EntityManager.js +23 -0
- package/package.json +2 -2
package/EntityManager.d.ts
CHANGED
|
@@ -264,6 +264,29 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
|
|
|
264
264
|
upsertMany<Entity extends object, Fields extends string = any>(entityNameOrEntity: EntityName<Entity> | Entity[], data?: (EntityData<Entity> | NoInfer<Entity>)[], options?: UpsertManyOptions<Entity, Fields>): Promise<Entity[]>;
|
|
265
265
|
/**
|
|
266
266
|
* Runs your callback wrapped inside a database transaction.
|
|
267
|
+
*
|
|
268
|
+
* If a transaction is already active, a new savepoint (nested transaction) will be created by default. This behavior
|
|
269
|
+
* can be controlled via the `propagation` option. Use the provided EntityManager instance for all operations that
|
|
270
|
+
* should be part of the transaction. You can safely use a global EntityManager instance from a DI container, as this
|
|
271
|
+
* method automatically creates an async context for the transaction.
|
|
272
|
+
*
|
|
273
|
+
* **Concurrency note:** When running multiple transactions concurrently (e.g. in parallel requests or jobs), use the
|
|
274
|
+
* `clear: true` option. This ensures the callback runs in a clear fork of the EntityManager, providing full isolation
|
|
275
|
+
* between concurrent transactional handlers. Using `clear: true` is an alternative to forking explicitly and calling
|
|
276
|
+
* the method on the new fork – it already provides the necessary isolation for safe concurrent usage.
|
|
277
|
+
*
|
|
278
|
+
* **Propagation note:** Changes made within a transaction (whether top-level or nested) are always propagated to the
|
|
279
|
+
* parent context, unless the parent context is a global one. If you want to avoid that, fork the EntityManager first
|
|
280
|
+
* and then call this method on the fork.
|
|
281
|
+
*
|
|
282
|
+
* **Example:**
|
|
283
|
+
* ```ts
|
|
284
|
+
* await em.transactional(async (em) => {
|
|
285
|
+
* const author = new Author('Jon');
|
|
286
|
+
* em.persist(author);
|
|
287
|
+
* // flush is called automatically at the end of the callback
|
|
288
|
+
* });
|
|
289
|
+
* ```
|
|
267
290
|
*/
|
|
268
291
|
transactional<T>(cb: (em: this) => T | Promise<T>, options?: TransactionOptions): Promise<T>;
|
|
269
292
|
/**
|
package/EntityManager.js
CHANGED
|
@@ -971,6 +971,29 @@ class EntityManager {
|
|
|
971
971
|
}
|
|
972
972
|
/**
|
|
973
973
|
* Runs your callback wrapped inside a database transaction.
|
|
974
|
+
*
|
|
975
|
+
* If a transaction is already active, a new savepoint (nested transaction) will be created by default. This behavior
|
|
976
|
+
* can be controlled via the `propagation` option. Use the provided EntityManager instance for all operations that
|
|
977
|
+
* should be part of the transaction. You can safely use a global EntityManager instance from a DI container, as this
|
|
978
|
+
* method automatically creates an async context for the transaction.
|
|
979
|
+
*
|
|
980
|
+
* **Concurrency note:** When running multiple transactions concurrently (e.g. in parallel requests or jobs), use the
|
|
981
|
+
* `clear: true` option. This ensures the callback runs in a clear fork of the EntityManager, providing full isolation
|
|
982
|
+
* between concurrent transactional handlers. Using `clear: true` is an alternative to forking explicitly and calling
|
|
983
|
+
* the method on the new fork – it already provides the necessary isolation for safe concurrent usage.
|
|
984
|
+
*
|
|
985
|
+
* **Propagation note:** Changes made within a transaction (whether top-level or nested) are always propagated to the
|
|
986
|
+
* parent context, unless the parent context is a global one. If you want to avoid that, fork the EntityManager first
|
|
987
|
+
* and then call this method on the fork.
|
|
988
|
+
*
|
|
989
|
+
* **Example:**
|
|
990
|
+
* ```ts
|
|
991
|
+
* await em.transactional(async (em) => {
|
|
992
|
+
* const author = new Author('Jon');
|
|
993
|
+
* em.persist(author);
|
|
994
|
+
* // flush is called automatically at the end of the callback
|
|
995
|
+
* });
|
|
996
|
+
* ```
|
|
974
997
|
*/
|
|
975
998
|
async transactional(cb, options = {}) {
|
|
976
999
|
const em = this.getContext(false);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "6.5.6
|
|
3
|
+
"version": "6.5.6",
|
|
4
4
|
"description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"esprima": "4.0.1",
|
|
65
65
|
"fs-extra": "11.3.2",
|
|
66
66
|
"globby": "11.1.0",
|
|
67
|
-
"mikro-orm": "6.5.6
|
|
67
|
+
"mikro-orm": "6.5.6",
|
|
68
68
|
"reflect-metadata": "0.2.2"
|
|
69
69
|
}
|
|
70
70
|
}
|