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

collection.insertMany give type error when passed a readonly array

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 6.9.0
    • Affects Version/s: 5.9.0, 6.7.0
    • Component/s: None
    • 2
    • 1
    • Not Needed
    • Not Needed
    • 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 user
      I want to be able to pass tuple or ReadonlyArray to insertMany
      So that I don't have to cast the type

       

      current type is too restrictive (assuming that the method doesn't mutate it's `docs` argument)

      https://github.com/mongodb/node-mongodb-native/blob/5abf5fca0f6161b59784107abbfb06d6fd1471be/src/collection.ts#L294-L295

      User Impact

      • ReadonlyArrays are not accepted by the insertMany API. Using this type permits both readonly and mutable arrays, so readonly should be preferred since the driver does not mutate the array.

      Dependencies

      • None

      Unknowns

      • None

      Acceptance Criteria

      Implementation Requirements

      • insertMany should accept ReadonlyArray<OptionalUnlessRequiredId<TSchema>> for the docs argument.

      Testing Requirements

      • Add tsd type tests that a readonly array and mutable array are accepted to insertMany

      Documentation Requirements

      • None

      Follow Up Requirements

      • See linked tickets

            Assignee:
            neal.beeken@mongodb.com Neal Beeken
            Reporter:
            adrian.gierakowski@deversifi.com Adrian Gierakowski
            Bailey Pearson
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: