From 56518062512712bb584bb3bc4b9cee4783a49986 Mon Sep 17 00:00:00 2001 From: Filip Weiss Date: Mon, 3 Jun 2024 12:30:39 +0200 Subject: [PATCH 1/2] docs: add note about parallelism in transations Analog to mongodb driver docs update: https://github.com/mongodb/node-mongodb-native/pull/4122 --- docs/transactions.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/transactions.md b/docs/transactions.md index 4251cd5d017..cb3d8a93add 100644 --- a/docs/transactions.md +++ b/docs/transactions.md @@ -3,6 +3,11 @@ [Transactions](https://www.mongodb.com/transactions) let you execute multiple operations in isolation and potentially undo all the operations if one of them fails. This guide will get you started using transactions with Mongoose. +

Note About Parallelism in Transactions

+ +Running operations in parallel is **not supported** during a transaction. The use of `Promise.all`, `Promise.allSettled`, `Promise.race`, etc. to parallelize operations inside a transaction is +undefined behaviour and should be avoided. +

Getting Started with Transactions

If you haven't already, import mongoose: From 77083a571701ab018586ef276fba4008cb9352bd Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Tue, 4 Jun 2024 18:13:38 -0400 Subject: [PATCH 2/2] Update transactions.md --- docs/transactions.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/transactions.md b/docs/transactions.md index cb3d8a93add..bafd16a0164 100644 --- a/docs/transactions.md +++ b/docs/transactions.md @@ -3,11 +3,6 @@ [Transactions](https://www.mongodb.com/transactions) let you execute multiple operations in isolation and potentially undo all the operations if one of them fails. This guide will get you started using transactions with Mongoose. -

Note About Parallelism in Transactions

- -Running operations in parallel is **not supported** during a transaction. The use of `Promise.all`, `Promise.allSettled`, `Promise.race`, etc. to parallelize operations inside a transaction is -undefined behaviour and should be avoided. -

Getting Started with Transactions

If you haven't already, import mongoose: @@ -66,6 +61,11 @@ await db.transaction(async function setRank(session) { doc.isNew; ``` +

Note About Parallelism in Transactions

+ +Running operations in parallel is **not supported** during a transaction. The use of `Promise.all`, `Promise.allSettled`, `Promise.race`, etc. to parallelize operations inside a transaction is +undefined behaviour and should be avoided. +

With Mongoose Documents and save()

If you get a [Mongoose document](documents.html) from [`findOne()`](api/model.html#model_Model-findOne)