I have a very complex json document in mongo like below:
{
"Category": [
{
"Name" : "",
"Description": "",
"SubCategory" : [
{
"Name": "",
"Description": "",
"Services": [
{"ServiceA": [
{
"Name": "",
"Description": "",
"CodeA": "1234"
}
]},
{"ServiceB" : [
{
"Name": "",
"Description": "",
"CodeBC": "ABCD",
"Key": ""
}
]},
{"ServiceC": [
{
"Name": "",
"Description": "",
"CodeBC": "ABCD",
"Section": [
{
"Name": "",
"Description": ""
}
]
}
]}
]
}
]
}
]
}
Now I want to retrieve the same document from Mongo but I want it to match only those objects inside ServiceA having CodeA = "1234" and those inside ServiceB and ServiceC having CodeBC = "ABCD".
I want it to remove all other objects inside ServiceA, ServiceB and ServiceC not matching the above condition and retrieve the document while maintaining the structure as it is.
Please Note : In the above example I just showed arrays containing single objects and fields that I want to retrieve but in real case it's very complex.