[SERVER-825] $pullAll API is not consistent with $pull API Created: 24/Mar/10 Updated: 10/Jun/11 Resolved: 08/Apr/10 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Usability |
| Affects Version/s: | 1.4.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Michael Sheakoski | Assignee: | Eliot Horowitz (Inactive) |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Participants: |
| Description |
|
I'm trying to pull multiple hashes from an array but only know the value of one of the hash keys. I expected $pullAll to work in a similar manner to $pull but got an error message instead. use temp db.bands.save({ , , , {name: 'Ringo', instrument: 'drums'} ] db.bands.update({}, {$pull: {members: {instrument: 'drums'}}}) db.bands.update({}, {$pullAll: {members: {instrument: ['guitar', 'bass']}}}) db.bands.update({}, { , , {name: 'George', instrument: 'guitar'} ]} db.bands.find() |
| Comments |
| Comment by Moses Nakamura [ 10/Jun/11 ] |
|
I also ran into this--it is confusing that pullAll has different behavior than pull. There should at least be a note in the API that pullAll only supports exact matches. |
| Comment by Eliot Horowitz (Inactive) [ 13/May/10 ] |
|
Please see above comment. |
| Comment by wangdebing [ 13/May/10 ] |
|
please re-open I also encountered this problem v 1.4.1 |
| Comment by Eliot Horowitz (Inactive) [ 08/Apr/10 ] |
|
see for an example please re-open if there is something i missed |
| Comment by Eliot Horowitz (Inactive) [ 08/Apr/10 ] |
|
on futher though, i'm not sure this makes sense. $pullAll seems to make more sense to me as exact matches instead of , {instrument: 'bass'} ] you should be able to do } } |
| Comment by Michael Sheakoski [ 24/Mar/10 ] |
|
After speaking with Michael Dirolf, this is the API he suggested: db.bands.update({}, , {instrument: 'bass'} ] This would make it consistent with $pull once it is implemented. |
| Comment by Michael Dirolf [ 24/Mar/10 ] |
|
oops - closed prematurely. didn't realize the behavior for $pull had changed. still i think the array in the example will need to be moved up one level. |
| Comment by Michael Dirolf [ 24/Mar/10 ] |
|
$pullAll takes an array, not a document - it pulls all items in the array. |