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

Stages of aggregation pipeline could be strictly typed

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Trivial - P5 Trivial - P5
    • None
    • Affects Version/s: None
    • Component/s: TypeScript

      Currently the stages of an aggregation pipeline are loosely or incorrectly typed. The signature of the "aggregate" method uses a "T extends Document = Document" template parameter which turns into "any". I couldn't make out what Document is in this context, but I believe it should be a union with all the possible aggregation operators instead.

      If for some reason this typing is hard to implement, is still possible to make the type less loose (the pipeline stage will always consist of a object with a single key in it, the key starting with a dollar sign and being a valid aggregation operator).

      I have a running code base which makes extensive use of aggregations, and a lot of trouble could be saved during the build time. It's not anything urgent, but I think such relatively easy improvement could be made into the next release.

      Let me know if I could help any further by opening a PR. Thanks!

       

            Assignee:
            neal.beeken@mongodb.com Neal Beeken
            Reporter:
            joaosan177@gmail.com João Santos
            Votes:
            3 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: