Skip to content

Commit bacf3cf

Browse files
authored
fix(NODE-6328): pass through optional options in txn APIs (#45)
1 parent a54d25e commit bacf3cf

File tree

3 files changed

+27
-13
lines changed

3 files changed

+27
-13
lines changed

readme.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ In your existing project add `mongodb-legacy` to your `package.json` with the fo
6262
npm install mongodb-legacy
6363
```
6464

65-
65+
6666
### Release Integrity
6767

6868
Releases are created automatically and signed using the [Node team's GPG key](https://pgp.mongodb.com/node-driver.asc). This applies to the git tag as well as all release packages provided as part of a GitHub release. To verify the provided packages, download the key and import it using gpg:
@@ -74,9 +74,9 @@ gpg --import node-driver.asc
7474
The GitHub release contains a detached signature file for the NPM package (named
7575
`mongodb-legacy-X.Y.Z.tgz.sig`).
7676

77-
The following command returns the link npm package.
77+
The following command returns the link npm package.
7878
```shell
79-
npm view [email protected] dist.tarball
79+
npm view [email protected] dist.tarball
8080
```
8181

8282
Using the result of the above command, a `curl` command can return the official npm package for the release.
@@ -86,10 +86,8 @@ To verify the integrity of the downloaded package, run the following command:
8686
gpg --verify mongodb-legacy-X.Y.Z.tgz.sig mongodb-legacy-X.Y.Z.tgz
8787
```
8888

89-
>[!Note]
90-
No verification is done when using npm to install the package. The contents of the Github tarball and npm's tarball are identical.
91-
92-
```
89+
>[!NOTE]
90+
> No verification is done when using npm to install the package. The contents of the Github tarball and npm's tarball are identical.
9391
9492
### Versioning
9593

src/legacy_wrappers/session.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,28 @@ Object.defineProperty(module.exports, '__esModule', { value: true });
77

88
module.exports.makeLegacyClientSession = function (baseClass) {
99
class LegacyClientSession extends baseClass {
10-
abortTransaction(callback) {
11-
return maybeCallback(super.abortTransaction(), callback);
10+
abortTransaction(options, callback) {
11+
callback =
12+
typeof callback === 'function'
13+
? callback
14+
: typeof options === 'function'
15+
? options
16+
: undefined;
17+
options = typeof options !== 'function' ? options : undefined;
18+
19+
return maybeCallback(super.abortTransaction(options), callback);
1220
}
1321

14-
commitTransaction(callback) {
15-
return maybeCallback(super.commitTransaction(), callback);
22+
commitTransaction(options, callback) {
23+
callback =
24+
typeof callback === 'function'
25+
? callback
26+
: typeof options === 'function'
27+
? options
28+
: undefined;
29+
options = typeof options !== 'function' ? options : undefined;
30+
31+
return maybeCallback(super.commitTransaction(options), callback);
1632
}
1733

1834
endSession(options, callback) {

test/tools/api.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ const api = [
5757
{ className: 'ChangeStream', method: 'next', returnType: 'Promise<TChange>' },
5858
{ className: 'ChangeStream', method: 'tryNext', returnType: 'Promise<Document | null>' },
5959

60-
{ className: 'ClientSession', method: 'abortTransaction', returnType: 'Promise<Document>' },
61-
{ className: 'ClientSession', method: 'commitTransaction', returnType: 'Promise<Document>' },
60+
{ className: 'ClientSession', method: 'abortTransaction', returnType: 'Promise<Document>', possibleCallbackPositions: [1, 2] },
61+
{ className: 'ClientSession', method: 'commitTransaction', returnType: 'Promise<Document>', possibleCallbackPositions: [1, 2] },
6262
{ className: 'ClientSession', method: 'endSession', returnType: 'Promise<void>' },
6363
{ className: 'ClientSession', method: 'withTransaction', returnType: 'Promise<void>', notAsync: true },
6464

0 commit comments

Comments
 (0)