[SERVER-786] Update a size field with addToSet Created: 18/Mar/10 Updated: 06/Dec/22 Resolved: 29/Jun/19 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Write Ops |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Marc Seeger | Assignee: | Backlog - Query Team (Inactive) |
| Resolution: | Done | Votes: | 20 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Assigned Teams: |
Query
|
||||||||
| Participants: | |||||||||
| Description |
|
As mentioned over here: http://groups.google.com/group/mongodb-user/browse_thread/thread/9c4e2a157cc8e0c9 It would be nice to have the ability to update a size field when doing a pushToSet (especially in connection with more than one element and $each). One can't simply use $inc since there is no information how many elements were actually pushed |
| Comments |
| Comment by Asya Kamsky [ 29/Jun/19 ] | ||||
|
You can see some examples here. This can be handled by setting a size field to {$size:<array>} after the $addToSet (which would be $setUnion in aggregation syntax.
| ||||
| Comment by Asya Kamsky [ 16/May/17 ] | ||||
|
Related to conditional updates | ||||
| Comment by Piyush Verma [ 02/Nov/12 ] | ||||
|
+1 https://jira.mongodb.org/browse/SERVER-4376 is Similar. |