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

Incorrect default aggregation generic type

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.1.3
    • Affects Version/s: 4.1.2
    • Component/s: TypeScript
    • 2
    • None
    • Not Needed
    • None
    • None
    • None
    • None
    • None
    • None

      Hello,

      Since typings got added to the library in 4.0 and DefinitelyTyped's typings are no longer needed, this issue (.aggregate assumes the resulting document will be of the same object type as the collection's document) still persists.  Here is what is currently being distributed in 4.1.1 (1 of 2 places aggregate is defined):

          /**
           * Execute an aggregation framework pipeline against the collection, needs MongoDB \>= 2.2
           *
           * @param pipeline - An array of aggregation pipelines to execute
           * @param options - Optional settings for the command
           */
          aggregate<T = TSchema>(pipeline?: Document[], options?: AggregateOptions): AggregationCursor<T>;
      

      Updating AggregationCursor<T> to AggregationCursor<unknown> fixes things for me.  Alternatively, it may be possible to refactor the AggregationCursor class to not be generic.

      Acceptance Criteria
      *

            Assignee:
            neal.beeken@mongodb.com Neal Beeken
            Reporter:
            alexander.golin@mongodb.com Alexander Golin (Inactive)
            Daria Pardue
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: