Skip to content
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

feat: reintroduce clone and rewind for cursors #2647

Merged
merged 2 commits into from
Dec 2, 2020

Conversation

mbroadst
Copy link
Member

@mbroadst mbroadst commented Dec 1, 2020

Description

These two commits add back support for cloning and rewinding cursors.

What changed?
The changes should be fairly straightforward, but I wanted to call out a few design decisions:
- I had originally intended clone to be an abstract method on AbstractCursor, forcing us to implement it for all possible cursor subclasses. This would have unfortunately required us to make AbstractCursor generic over the subclass types, since the following signature results in type ambiguity at the point of implementation in the subclass: abstract clone(): this

  • Therefore, clone is implemented by hand in AbstractCursor subclasses. I only implemented it for FindCursor and AggregateCursor because it's likely that's where legacy users have actually used this feature.

  • There is a correction in the rewind implementation regarding sessions. When a session is started as part of cursor initialization I had originally marked this as an explicit: true start, however, this is clearly an implicit session the driver is creating in the absence of an explicitly provided one.

Are there any files to ignore?
none

This reintroduces support for rewinding a cursor to its
uninitialized state.

NODE-2811
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, mod one typo

@@ -49,6 +49,16 @@ export class FindCursor extends AbstractCursor {
}
}

/**
* Returns a new unitialized copy of this cursor, with options matching those that have been set on the current instance
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Returns a new unitialized copy of this cursor, with options matching those that have been set on the current instance
* Returns a new uninitialized copy of this cursor, with options matching those that have been set on the current instance

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed here and in aggregation_cursor too!

@mbroadst mbroadst force-pushed the NODE-2811/rewind-clone-support branch from df0b77e to 59c5de2 Compare December 2, 2020 19:30
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 one suggestion
If we do want the abstract clone I think it's still available to us:

src/cursor/find_cursor.ts Show resolved Hide resolved
@mbroadst mbroadst force-pushed the NODE-2811/rewind-clone-support branch from 59c5de2 to 7bbc569 Compare December 2, 2020 20:17
@mbroadst mbroadst merged commit a5154fb into master Dec 2, 2020
@mbroadst mbroadst deleted the NODE-2811/rewind-clone-support branch December 2, 2020 22:56
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