-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: 1.4.0
-
Component/s: Usability
-
None
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.dropDatabase()
db.bands.save({
name: 'The Beatles',
members: [
,
,
,
{name: 'Ringo', instrument: 'drums'} ]
})
db.bands.update({}, {$pull: {members:
{instrument: 'drums'}}})
// Ringo is removed
db.bands.update({}, {$pullAll: {members:
{instrument: ['guitar', 'bass']}}})
// John, Paul, and George should be removed but get this error instead:
// Modifier $pushAll/pullAll allowed for arrays only
db.bands.update({}, {
$pullAll: {members: [
,
,
{name: 'George', instrument: 'guitar'} ]}
})
// It works if you specify the EXACT hash
db.bands.find()