[SERVER-28283] possible to obtain id for modified record in updateOne result? Created: 12/Mar/17 Updated: 31/May/17 Resolved: 13/Mar/17 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | tony kerz | Assignee: | Mark Agarunov |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Participants: |
| Description |
|
upsertedId is populated for upsert operations. would it be possible to include something like an updatedId to report on the id of the modified record? i have a situation where i am going after a record with a query not involving _id, but i subsequently need the value of _id |
| Comments |
| Comment by Mark Agarunov [ 13/Mar/17 ] |
|
Hello tony-kerz, Thank you for the report. From what you've described, the findAndModify operation may provide the behavior you're looking for. This will update a document as well as return it, note however that the new option must be passed to return the modified document, otherwise the document is returned before modification. Please note that SERVER project is for reporting bugs or feature suggestions for the MongoDB server. For MongoDB-related support discussion please post on the mongodb-user group or Stack Overflow with the mongodb tag. A question like this involving more discussion would be best posted on the mongodb-user group. Thanks, |