|
44 | 44 | <p>Options for the transaction</p>
|
45 | 45 | </div></div></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a id="toBSON" class="tsd-anchor"></a><h3 class="tsd-anchor-link">toBSON<a href="#toBSON" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">toBSON<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">never</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/mongodb/node-mongodb-native/blob/main/src/sessions.ts#L455">src/sessions.ts:455</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
46 | 46 | <p>This is here to ensure that ClientSession is never serialized to BSON.</p>
|
47 |
| -</div></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">never</span></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter"><a id="withTransaction" class="tsd-anchor"></a><h3 class="tsd-anchor-link">with<wbr/>Transaction<a href="#withTransaction" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter"><li class="tsd-signature tsd-kind-icon">with<wbr/>Transaction<span class="tsd-signature-symbol"><</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">T</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span>fn<span class="tsd-signature-symbol">: </span><a href="../modules.html#WithTransactionCallback" class="tsd-signature-type" data-tsd-kind="Type alias">WithTransactionCallback</a><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">T</span><span class="tsd-signature-symbol">></span>, options<span class="tsd-signature-symbol">?: </span><a href="../interfaces/TransactionOptions.html" class="tsd-signature-type" data-tsd-kind="Interface">TransactionOptions</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">T</span><span class="tsd-signature-symbol">></span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/mongodb/node-mongodb-native/blob/main/src/sessions.ts#L470">src/sessions.ts:470</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> |
48 |
| -<p>Runs a provided lambda within a transaction, retrying either the commit operation |
| 47 | +</div></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">never</span></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter"><a id="withTransaction" class="tsd-anchor"></a><h3 class="tsd-anchor-link">with<wbr/>Transaction<a href="#withTransaction" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter"><li class="tsd-signature tsd-kind-icon">with<wbr/>Transaction<span class="tsd-signature-symbol"><</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">T</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span>fn<span class="tsd-signature-symbol">: </span><a href="../modules.html#WithTransactionCallback" class="tsd-signature-type" data-tsd-kind="Type alias">WithTransactionCallback</a><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">T</span><span class="tsd-signature-symbol">></span>, options<span class="tsd-signature-symbol">?: </span><a href="../interfaces/TransactionOptions.html" class="tsd-signature-type" data-tsd-kind="Interface">TransactionOptions</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">undefined</span><span class="tsd-signature-symbol"> | </span><a href="../interfaces/Document.html" class="tsd-signature-type" data-tsd-kind="Interface">Document</a><span class="tsd-signature-symbol">></span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/mongodb/node-mongodb-native/blob/main/src/sessions.ts#L480">src/sessions.ts:480</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> |
| 48 | +<p>Runs a provided callback within a transaction, retrying either the commitTransaction operation |
49 | 49 | or entire transaction as needed (and when the error permits) to better ensure that
|
50 | 50 | the transaction can complete successfully.</p>
|
51 |
| -</div><div><p>IMPORTANT: This method requires the user to return a Promise, all lambdas that do not |
52 |
| -return a Promise will result in undefined behavior.</p> |
53 |
| -</div></div><h4 class="tsd-type-parameters-title">Type parameters</h4><ul class="tsd-type-parameters"><li><h4>T = <span class="tsd-signature-type">void</span></h4></li></ul><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>fn: <a href="../modules.html#WithTransactionCallback" class="tsd-signature-type" data-tsd-kind="Type alias">WithTransactionCallback</a><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">T</span><span class="tsd-signature-symbol">></span></h5><div class="tsd-comment tsd-typography"><div class="lead"> |
54 |
| -<p>A lambda to run within a transaction</p> |
| 51 | +</div><div><p><strong>IMPORTANT:</strong> This method requires the user to return a Promise, and <code>await</code> all operations. |
| 52 | +Any callbacks that do not return a Promise will result in undefined behavior.</p> |
| 53 | +</div><dl class="tsd-comment-tags"><dt>remarks</dt><dd><p>This function:</p> |
| 54 | +<ul> |
| 55 | +<li>Will return the command response from the final commitTransaction if every operation is successful (can be used as a truthy object)</li> |
| 56 | +<li>Will return <code>undefined</code> if the transaction is explicitly aborted with <code>await session.abortTransaction()</code></li> |
| 57 | +<li>Will throw if one of the operations throws or <code>throw</code> statement is used inside the <code>withTransaction</code> callback</li> |
| 58 | +</ul> |
| 59 | +<p>Checkout a descriptive example here:</p> |
| 60 | +</dd><dt>see</dt><dd><p><a href="https://www.mongodb.com/developer/quickstart/node-transactions/">https://www.mongodb.com/developer/quickstart/node-transactions/</a></p> |
| 61 | +</dd></dl></div><h4 class="tsd-type-parameters-title">Type parameters</h4><ul class="tsd-type-parameters"><li><h4>T = <span class="tsd-signature-type">void</span></h4></li></ul><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>fn: <a href="../modules.html#WithTransactionCallback" class="tsd-signature-type" data-tsd-kind="Type alias">WithTransactionCallback</a><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">T</span><span class="tsd-signature-symbol">></span></h5><div class="tsd-comment tsd-typography"><div class="lead"> |
| 62 | +<p>callback to run within a transaction</p> |
55 | 63 | </div></div></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> options: <a href="../interfaces/TransactionOptions.html" class="tsd-signature-type" data-tsd-kind="Interface">TransactionOptions</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
|
56 |
| -<p>Optional settings for the transaction</p> |
57 |
| -</div></div></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type" data-tsd-kind="Type parameter">T</span><span class="tsd-signature-symbol">></span></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-static tsd-is-external"><a id="getEventListeners" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagStatic">Static</span> get<wbr/>Event<wbr/>Listeners<a href="#getEventListeners" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-static tsd-is-external"><li class="tsd-signature tsd-kind-icon">get<wbr/>Event<wbr/>Listeners<span class="tsd-signature-symbol">(</span>emitter<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">DOMEventTarget</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">EventEmitter</span>, name<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">symbol</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Function</span><span class="tsd-signature-symbol">[]</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><p>Inherited from <a href="TypedEventEmitter.html">TypedEventEmitter</a>.<a href="TypedEventEmitter.html#getEventListeners">getEventListeners</a></p><ul><li>Defined in node_modules/@types/node/events.d.ts:270</li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> |
| 64 | +<p>optional settings for the transaction</p> |
| 65 | +</div></div></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">undefined</span><span class="tsd-signature-symbol"> | </span><a href="../interfaces/Document.html" class="tsd-signature-type" data-tsd-kind="Interface">Document</a><span class="tsd-signature-symbol">></span></h4><div><p>A raw command response or undefined</p> |
| 66 | +</div></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-static tsd-is-external"><a id="getEventListeners" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span class="tsd-flag ts-flagStatic">Static</span> get<wbr/>Event<wbr/>Listeners<a href="#getEventListeners" aria-label="Permalink" class="tsd-anchor-icon"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></svg></a></h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-inherited tsd-is-static tsd-is-external"><li class="tsd-signature tsd-kind-icon">get<wbr/>Event<wbr/>Listeners<span class="tsd-signature-symbol">(</span>emitter<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">DOMEventTarget</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">EventEmitter</span>, name<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">symbol</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Function</span><span class="tsd-signature-symbol">[]</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><p>Inherited from <a href="TypedEventEmitter.html">TypedEventEmitter</a>.<a href="TypedEventEmitter.html#getEventListeners">getEventListeners</a></p><ul><li>Defined in node_modules/@types/node/events.d.ts:270</li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead"> |
58 | 67 | <p>Returns a copy of the array of listeners for the event named <code>eventName</code>.</p>
|
59 | 68 | </div><div><p>For <code>EventEmitter</code>s this behaves exactly the same as calling <code>.listeners</code> on
|
60 | 69 | the emitter.</p>
|
|
0 commit comments