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

`BulkWrite()` method does not allow accessing `InsertedIDs` from its response

    • Type: Icon: Task Task
    • Resolution: Duplicate
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Go Drivers
    • 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?

      Context

      The mongo go driver has a method BulkWrite for executing bulkwrite operations as mentioned in the [documentation|https://www.mongodb.com/docs/drivers/go/current/usage-examples/bulkWrite/.] The BulkWrite method accepts a "WriteModel", which is implemented by "UpdateOneModel" and "InsertOneModel". However, when I pass an array of "InsertOneModel" into BulkWrite, it does not offer any "InsertedIDs" property to be able to access the IDs of what was inserted. (There is an "upsertedIDs" property, but it is empty when using InsertOneModels within bulkWrite)

       

      This is odd since the standard mongosh command does allow accessing the insertedIds from the response of BulkWrite (see first example in the documentation), so it looks like the Mongo driver's BulkWrite method is missing an option that should be returned by default.

      Definition of done

      What must be done to consider the task complete?

      • The "InsertedIDs" option should be made available on the mongo.BulkWriteResult struct
      • The InsertedIDs should be populated with ids that bulkWrite inserted from the execution of "InsertOneModel" provided in the arguments 

      Pitfalls

      What should the implementer watch out for? What are the risks?

            Assignee:
            Unassigned Unassigned
            Reporter:
            haslam@forbes.com Habibullah Aslam
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: