Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-4715

Support mapping to `null`ish values in our cursors

    • Type: Icon: New Feature New Feature
    • Resolution: Won't Fix
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: Cursors
    • Labels:
    • Not Needed
    • Not Needed

      Our AbstractCursor iterator helper methods return `null` to indicate that the cursor has been completely iterated.  However, using `null` to indicate the "lack of another value" is problematic in the case where a user may want to map values to `null` because after mapping a value to `null`, we perceive the cursor as being exhausted and close it.

      See NODE-4609 as a recent bug report about this behavior.

      If our internal `next` helpers returned documents that conformed to the `iterator` protocol (documentation here) we could allow users to map to `null` values.

      Acceptance Criteria

      • Refactor the internal `next` method to return an iterator object instead of the raw document result.
      • Update our `Symbol.asyncIterator` implementation to call next directly and use the `done` property to determine when the cursor is exhausted instead of relying on the cursor returning a `null` value
      • Refactor `cursor.next`, `cursor.tryNext` and `cursor.hasNext` to unwrap the iterator object returned from `next` and return the value

            Assignee:
            Unassigned Unassigned
            Reporter:
            bailey.pearson@mongodb.com Bailey Pearson
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: