My mistake; I misunderstood the question.
If you want to remove all subobjects wherein a certain condition holds
true, you can use $pull with a sub-object selector (i.e., the selector
passes will be used to filter the array contents). Here's a quick
example:
> db.stuff.save({ 'arr': [ {'a': 1},{'a':2},{'a':2},{'a':3},{'a':2},{'a':3},{'a':3} ] })
> db.stuff.find()
{ "_id" : ObjectId("4e975f86955abc3e60f6d464"), "arr" :
[ { "a" : 1 }, { "a" : 2 }, { "a" :
2 }, { "a" : 3 }, { "a" : 2 },
{ "a" : 3 }, { "a" : 3 } ] }
> db.stuff.update({}, { '$pull': { 'arr': { 'a': 2 } } })
> db.stuff.find()
{ "_id" : ObjectId("4e975f86955abc3e60f6d464"), "arr" : [ { "a" : 1 },
{ "a" : 3 }, { "a" : 3 }, { "a" : 3 } ] }
>
- Brandon
On Oct 13, 5:38 pm, Sam Millman <
sam.mill...@gmail.com> wrote:
> find({ 'a.b': { $nin: {null}}}, {$unset: { 'a.$.b': 1 }}, false, true);
>
> this basically says:
>
> where a.b is not null unset it.
>
> This might work
>
> On 13 October 2011 22:28, Sam Grossberg <
sam.grossb...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Hmm...looks like I need to specify an array of values for that? The value
> > could be any integer...
>