{
"_id" : 160,
"info" : [
{
'name': 'Serg',
'proff': 'hacker'
},
null,
]
}
As you can see I have null element in my array, I need a general solution that will remove null elements from info array.
I tried this:
for doc in iter:
people.update({ '_id' : doc['_id']}, { '$pull' : { 'info' : 'null' }})
where iter
is a collection of documents. and people
is a collection
I also tried this in the shell:
> db.people.findAndModify({ query: {}, update: {'$pull': {info:null} } } )
But none of the above examples delete this null from my documents!! ))