You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -432,18 +432,16 @@ export class ClientSession extends TypedEventEmitter<ClientSessionEvents> {
432
432
}
433
433
434
434
/**
435
-
* Runs a provided callback within a transaction, retrying either the commitTransaction operation
436
-
* or entire transaction as needed (and when the error permits) to better ensure that
437
-
* the transaction can complete successfully.
435
+
* Starts a transaction and runs a provided function, ensuring the commitTransaction is always attempted when all operations run in the function have completed.
438
436
*
439
437
* **IMPORTANT:** This method requires the user to return a Promise, and `await` all operations.
440
-
* Any callbacks that do not return a Promise will result in undefined behavior.
441
438
*
442
439
* @remarks
443
440
* This function:
444
-
* - Will return the command response from the final commitTransaction if every operation is successful (can be used as a truthy object)
445
-
* - Will return `undefined` if the transaction is explicitly aborted with `await session.abortTransaction()`
446
-
* - Will throw if one of the operations throws or `throw` statement is used inside the `withTransaction` callback
441
+
* - If all operations successfully complete and the `commitTransaction` operation is successful, then this function will return the result of the provided function.
442
+
* - If the transaction is unable to complete or an error is thrown from within the provided function, then this function will throw an error.
443
+
* - If the transaction is manually aborted within the provided function it will not throw.
444
+
* - May be called multiple times if the driver needs to attempt to retry the operations.
0 commit comments