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

PushOperator and PullOperator reject all fields when the document type defines generic index access field

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: 6.4.0
    • Component/s: TypeScript
    • 2
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Use Case

      As a developer using TypeScript
      I want to define document types/interfaces using index access fields and use them together with $push and $pull operators
      So that I can use arrays in documents while define document structure freely

      Example

      interface Document {
        _id: string;
        foo?: string[];
        [key: string]: unknown;
      }
      
      db.getCollection<Document>(...)
        .updateOne(
          { ... },
          // @ts-expect-error - The line below is failing
          { $push: { foo: 'bar' } }
        );
      

      User Impact

      • We are not blocked with the upgrade but we have to use @ts-expect-error until this is fixed.

      Dependencies

      • upstream and/or downstream requirements and timelines to bear in mind

      Unknowns

      • A similar pattern may affect more operators.

      Acceptance Criteria

      Implementation Requirements

      • functional reqs, potential snafus to avoid, performance targets, etc

      Testing Requirements

      • unit test, spec test sync, etc

      Documentation Requirements

      • DOCSP ticket, API docs, etc

      Follow Up Requirements

      • additional tickets to file, required releases, etc

            Assignee:
            Unassigned Unassigned
            Reporter:
            mstekl@dnanexus.com Martin Štekl
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: