Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(cursor): modernize and deduplicate cursor classes
Since we merged core into native, there is no longer great need to maintain a fully functional "core" cursor type, it has become a private implementation detail. This changeset renames that class to `CoreCursor`, converts it to an ES6 class, and then builds the three public cursors on top of it. Here is a summary of changes: - All cursor classes are now ES6 classes - The `Cursor` from "core" has been renamed `CoreCursor` - a `CursorState` has been exported from the `CoreCursor` module so that all cursors may share a common state definition - `CoreCursor` extends `Readable` stream. Each of its subclasses inherited this, so this is where it naturally fits in the hierarchy. This wasn't possible before because the cursor exported by `mongodb-core` did not want to concern itself with higher concepts like streams. We are no longer shackled by this idea. - `CoreCursor` only exposes a public `_next` method because of the way the other cursors have traditionally subclassed it. - We still have `cursorState` and `s`, but they are only in _two_ locations now (`CoreCursor` has a `cursorState`, and `Cursor` has a `s). Eventually I think even these should be merged, but it did not seem important to distinguish this now. - All cursors had a _lot_ of duplicated properties. As much as possible these have been deduplicated, and include the following stored properties: bson, options, topology, topologyOptions, streamOptions, namespace, ns, cmd, promiseLibrary - generally sessions are stored and referred to by the core cursor's `cursorState`. We could move all functionality there eventually.
- Loading branch information
1 parent
feec4ba
commit 0f88582
Showing
31 changed files
with
1,719 additions
and
1,862 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.