[SERVER-2016] $pull with $elemMatch and $in does not work Created: 27/Oct/10 Updated: 09/Jul/16 Resolved: 17/Sep/13 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Write Ops |
| Affects Version/s: | 1.7.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Tony Hannan | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 4 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Wed Oct 27 08:59:28 db version v1.7.2-pre-, pdfile version 4.5 |
||
| Issue Links: |
|
||||||||
| Operating System: | ALL | ||||||||
| Participants: | |||||||||
| Description |
|
"db.bar.update({}, {$pull: {y: {$elemMatch: {a: 2}}}}, false, true)" works, but Sample document: , {a:2}]} |
| Comments |
| Comment by Andrew Morrow (Inactive) [ 17/Sep/13 ] |
|
Hi Tony - The argument to $pull is already applied to each element of the target array, so using $elemMatch is redundant in the update context. The workaround, as you suggested in your comment, is to just not use $elemMatch, and $pull will iterate over the array automatically. I'm going to close this as 'works as designed'. Please feel free to re-open if the above workaround is insufficient for you. We will also update the documentation to reflect that a top-level $elemMatch should not be provided to $pull. Thanks, |
| Comment by Tony Hannan [ 27/Oct/10 ] |
|
But "db.bar.update({}, {$pull: {y: {a: {$in: [2,3]}}}}, false, true)" does work. |