Normally you would use the following to remove a field from a collection. However the code below does not work for empty (""
) fields. How would you go about deleting an empty field in MongoDB?
db.collection.update({}, {$unset: {"": ""}}, {multi:true})
I get the following error message when I try this:
WriteResult({
"nMatched" : 0,
"nUpserted" : 0,
"nModified" : 0,
"writeError" : {
"code" : 56,
"errmsg" : "An empty update path is not valid."
}
})