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

Typescript cursor projection should be strongly typed

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

      How are you using Mongo? What version of the server and driver are you using?

      Using https://github.com/mongodb/node-mongodb-native through typescript

      What is the feauture/improvement you would like?

      The signature for `FindCursor<TSchema = Document>` `project` is
       
      ```

      project<T extends Document = Document>(value: Document): FindCursor<T>;

      ```

      I think this should be 

      ```

      project<T extends TSchema>(value: Toggle<T>): FindCursor<T>;

      ```

      where `Toggle<T> = {[keyof T]: 0 | 1}` has the right values.

      What use case would this feature/improvement enable?

      Better type safety for projections.

            Assignee:
            Unassigned Unassigned
            Reporter:
            tianhui.michael.li@gmail.com Tianhui Li
            None
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: