Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bulk upserts does not report upserted IDs #367

Open
smaurel opened this issue Jul 8, 2019 · 0 comments
Open

Bulk upserts does not report upserted IDs #367

smaurel opened this issue Jul 8, 2019 · 0 comments

Comments

@smaurel
Copy link

smaurel commented Jul 8, 2019

The bulk result structure does not contain UpsertedIDs, so it is impossible to know what IDs were inserted when upserting using bulk upsert.

The fact that this feature is missing is a problem for requests such as the following one, when I want to do something with IDs that were inserted.

db.my_collection.bulkWrite([{"updateOne": {"filter": {"not_id_field" : "10000000"}, "update": {"$setOnInsert": {"_id": "some_random_id"},"$addToSet": {"other_field": {"$each": ["100"]}}}, "upsert": true }}])

{ "acknowledged" : true, "deletedCount" : 0, "insertedCount" : 0, "matchedCount" : 0, "upsertedCount" : 1, "insertedIds" : {}, "upsertedIds" : { "0" : "some_random_id" } }

Request result comes from Mongo 4.0.6
EDIT: The request result is the same using Mongo 3.6.8

Wouldn't it be more complicated than just adding the upsertedIDs field in BulkUpdate structure and using the field in the Bulk's runUpdate method?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant