Skip to content

fix(NODE-6328): pass through optional options in txn APIs #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ In your existing project add `mongodb-legacy` to your `package.json` with the fo
npm install mongodb-legacy
```


### Release Integrity

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:
Expand All @@ -74,9 +74,9 @@ gpg --import node-driver.asc
The GitHub release contains a detached signature file for the NPM package (named
`mongodb-legacy-X.Y.Z.tgz.sig`).

The following command returns the link npm package.
The following command returns the link npm package.
```shell
npm view [email protected] dist.tarball
npm view [email protected] dist.tarball
```

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

>[!Note]
No verification is done when using npm to install the package. The contents of the Github tarball and npm's tarball are identical.

```
>[!NOTE]
> No verification is done when using npm to install the package. The contents of the Github tarball and npm's tarball are identical.
### Versioning

Expand Down
24 changes: 20 additions & 4 deletions src/legacy_wrappers/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,28 @@ Object.defineProperty(module.exports, '__esModule', { value: true });

module.exports.makeLegacyClientSession = function (baseClass) {
class LegacyClientSession extends baseClass {
abortTransaction(callback) {
return maybeCallback(super.abortTransaction(), callback);
abortTransaction(options, callback) {
callback =
typeof callback === 'function'
? callback
: typeof options === 'function'
? options
: undefined;
options = typeof options !== 'function' ? options : undefined;

return maybeCallback(super.abortTransaction(options), callback);
}

commitTransaction(callback) {
return maybeCallback(super.commitTransaction(), callback);
commitTransaction(options, callback) {
callback =
typeof callback === 'function'
? callback
: typeof options === 'function'
? options
: undefined;
options = typeof options !== 'function' ? options : undefined;

return maybeCallback(super.commitTransaction(options), callback);
}

endSession(options, callback) {
Expand Down
4 changes: 2 additions & 2 deletions test/tools/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ const api = [
{ className: 'ChangeStream', method: 'next', returnType: 'Promise<TChange>' },
{ className: 'ChangeStream', method: 'tryNext', returnType: 'Promise<Document | null>' },

{ className: 'ClientSession', method: 'abortTransaction', returnType: 'Promise<Document>' },
{ className: 'ClientSession', method: 'commitTransaction', returnType: 'Promise<Document>' },
{ className: 'ClientSession', method: 'abortTransaction', returnType: 'Promise<Document>', possibleCallbackPositions: [1, 2] },
{ className: 'ClientSession', method: 'commitTransaction', returnType: 'Promise<Document>', possibleCallbackPositions: [1, 2] },
{ className: 'ClientSession', method: 'endSession', returnType: 'Promise<void>' },
{ className: 'ClientSession', method: 'withTransaction', returnType: 'Promise<void>', notAsync: true },

Expand Down