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

Add a way to strongly type cursors that have transform functions defined

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Unknown
    • Resolution: Fixed
    • None
    • 4.0.0
    • None
    • None
    • Not Needed

    Description

      Currently if you call cursor.map(). There is no way to change the type that .next() returns based on the provided transform. We mitigate this problem by permitted user overrides in the various iteration methods.

      Example:

      const cursor = db.collection<Pet>().find().map(pet => pet.age)
      cursor.next() // still returns Pet
      cursor.next<number>() // Overridable generic parameter
      

      Attachments

        Activity

          People

            eric.adum@mongodb.com Eric Adum (Inactive)
            neal.beeken@mongodb.com Neal Beeken
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: