[SERVER-42741] getting back both _id of modified documents and writeResult information Created: 09/Aug/19 Updated: 06/Dec/22 |
|
| Status: | Backlog |
| Project: | Core Server |
| Component/s: | Shell, Usability |
| Affects Version/s: | 4.0.12, 4.2.0 |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Ben Rotz | Assignee: | Backlog - Query Execution |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||
| Assigned Teams: |
Query Execution
|
||||||||||||
| Participants: | |||||||||||||
| Case: | (copied to CRM) | ||||||||||||
| Description |
|
For many years I've fought with mongodb when I want to perform an upsert operation that both:
will give me nUpserted 1, and _id because the operation resulted in an upsert.
will give me nModified 1, but no _id because the operation was not an upsert. |
| Comments |
| Comment by Ben Rotz [ 12/Sep/19 ] | |||||||||||||||||||||
|
I’m not sure what the solution to 714 would look like so I’m not sure. However, your other linked issue https://jira.mongodb.org/browse/SERVER-28145 seems like what ok actually looking for. For my specific use case, ideally I could run a find and modify and get back both the old and the new document, as well as writeresult (nmodified, nmatched, etc.). I realize that getting back both old and new may introduce a lot of complexity to the internals that I don’t appreciate so I am content with merely getting back nmodified as stated in 28145. | |||||||||||||||||||||
| Comment by Asya Kamsky [ 12/Sep/19 ] | |||||||||||||||||||||
|
Looks like that improvement request already exists as SERVER-28145 which I linked to this ticket as well as SERVER-714 | |||||||||||||||||||||
| Comment by Asya Kamsky [ 12/Sep/19 ] | |||||||||||||||||||||
|
> [findAndModify returns] no WriteResult Note that while the shell helper just returns the document (old or new) the findAndModify command returns result in this format:
Unfortunately it seems to not have a way to return information differentiating existing found and updated and existing found and update was a no-op. I'll look into this and file a SERVER ticket if appropriate. | |||||||||||||||||||||
| Comment by Asya Kamsky [ 12/Sep/19 ] | |||||||||||||||||||||
|
ben@ethika.com it seems like this would be possible if SERVER-714 was implemented, would you agree?
| |||||||||||||||||||||
| Comment by Danny Hatcher (Inactive) [ 15/Aug/19 ] | |||||||||||||||||||||
|
Thanks for the report and the examples. I'll forward this along to the appropriate team to decide possible next steps. |