Skip to content

NODE-2815: alternative no generic parameter for options #2659

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 1 commit into from
Dec 4, 2020

Conversation

mbroadst
Copy link
Member

@mbroadst mbroadst commented Dec 3, 2020

Description

This is the most basic work required to remove the generic options type for the OperationBase type. The general rule of thumb was to add an options property to each subclass with a concrete type specific to that operation. Other work includes:

  • renamed OperationBase to AbstractOperation in keeping with the convention introduced in the AbstractCursor work
  • minor fixes uncovered when making options stricter (things like readPreference being stored on a copy of options in the base class)

@mbroadst mbroadst requested review from emadum and nbbeeken December 3, 2020 14:58
@mbroadst mbroadst force-pushed the NODE-2815/no-generic-parameter-for-options branch from c482c5c to 68a550e Compare December 3, 2020 15:00
@@ -49,21 +47,22 @@ export abstract class OperationBase<
// BSON serialization options
bsonOptions?: BSONSerializeOptions;

constructor(options: T = {} as T) {
this.options = Object.assign({}, options);
[kSession]: ClientSession;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be [kSession]?: ClientSession I guess TS has some issues around symbol properties that it's not enforcing this.

@nbbeeken nbbeeken self-requested a review December 3, 2020 23:29
@mbroadst mbroadst force-pushed the NODE-2815/no-generic-parameter-for-options branch 2 times, most recently from e7db3a9 to 6ccab2b Compare December 4, 2020 13:14
Copy link
Contributor

@nbbeeken nbbeeken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two Qs, thanks for combing through the || => ??!

Copy link
Contributor

@emadum emadum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

Copy link
Contributor

@nbbeeken nbbeeken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

This removes the generic options property of the base class for
all operations, in favor of storing those options on the concrete
operations. The work entailed a few major changes to the codebase:
  - renaming OperationBase to AbstractOperation (in keeping with
    similar naming conventions for cursors)
  - requiring sessions to be managed at the `execute` level for
    concrete operations
  - finally, removing the generic type parameter for operation
    definitions

NODE-2815
@mbroadst mbroadst force-pushed the NODE-2815/no-generic-parameter-for-options branch from ea7ce79 to f7275ce Compare December 4, 2020 21:34
@mbroadst mbroadst merged commit a52767f into master Dec 4, 2020
@mbroadst mbroadst deleted the NODE-2815/no-generic-parameter-for-options branch December 4, 2020 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants