I would like to remove all key/value pairs where the key is url
from all documents inside a mongodb collection.
I've been agonising over this all weekend and have only managed to partially solve it using $unset
, but I'm struggling to access all items particularly key/values inside objects in arrayKey
and also do it in one query/function (if possible).
This is generally how each document looks. There sometimes may be more objects in the arrayKey
, but other than that they're pretty similar:
{
"keyOne": "String",
"keyTwo": 7,
"keyThree": {
"subKeyOne": "String",
"url": "String"
},
"arrayKey": [
{
"arrayKeyOne":"String",
"url": "String"
},
{
"arrayKeyOne":"String",
"url": "String"
}
],
"url":"String"
}
Any help would be greatly appreciated. I'm still new to programming and mongodb so the documentation is a bit dense for a beginner.
Thanks :)