[SERVER-35719] how to update element in array using different update document Created: 21/Jun/18 Updated: 23/Jul/18 Resolved: 21/Jun/18 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | 3.6.5 |
| Fix Version/s: | None |
| Type: | Question | Priority: | Major - P3 |
| Reporter: | jipeng | Assignee: | Nick Brewer |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Participants: |
| Description |
|
suppose the document below: {{}}
{{}} how did i update the element with id =1 to make its num decrease 2 and the element with id =2 to make its num decrease 3 in a single statement? |
| Comments |
| Comment by Nick Brewer [ 21/Jun/18 ] |
|
Thanks for your report. Please note that the 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. I'd suggest taking a look at the arrayFilters section within the db.collections.updateOne documentation, as well as the $inc operator, which can be used to increment numeric values by a set amount. Regards, |