Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-2582

Accept any value for "documents" in InsertMany

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 2.0.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Major Change
    • 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?

      Currently, Collection.InsertMany accepts a []interface for the list of documents to insert. However, that API often requires users to copy their existing slice of documents to a slice of type []interface, adding unnecessary repeated code and unnecessary data copies. Improve the API by changing the documents parameter type to interface and use reflection to require users to pass in a array type (i.e. array or slice).

      This ticket was created based on a proposed improvement in a community PR.

      Definition of done:

      • Change the documents parameter in InsertMany to any instead of []any.
      • Return an error if the value passed to the documents parameter is not a slice. That avoids ambiguity between inserting many documents and inserting a single document that is an array.
      • Add an InsertMany benchmark and compare the performance before/after. Require that there is no significant performance impact.

            Assignee:
            steve.silvester@mongodb.com Steve Silvester
            Reporter:
            matt.dale@mongodb.com Matt Dale
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: