This is a question based on MongoDb - remove all fields that are null. The referred post only gives solution that removes null fields at the top level. However, how can I remove the null fields that embedded?
Please note that I have no idea of the possible names of the null fields and their depth, so I think we have to iterate over each field of each document.
This is an example:
{
"id": 14770467,
"f1": "a",
"f2": null,
"f3": [
{
"id": 76946819,
"f4": null
}
]
}
I'm expecting something like this:
{
"id": 14770467,
"f1": "a",
"f3": [
{
"id": 76946819
}
]
}
Thanks.