{
"id": 1,
"holdDetails": [
{
"holdDescription": "COVERT_LOCK",
"holdStatus": "CREATED"
},
{
"holdDescription": "ALPH_LOCK",
"holdStatus": "RESOLVED"
}
]
},
{
"id": 2,
"holdDetails": [
{
"holdDescription": "ALPHA_LOCK",
"holdStatus": "RESOLVED"
},
{
"holdDescription": "BETA_LOCK",
"holdStatus": "RESOLVED"
}
]
},
{
"id": 3,
"holdDetails": [
{
"holdDescription": "ALPHA_LOCK",
"holdStatus": "CREATED"
},
{
"holdDescription": "BETA_LOCK",
"holdStatus": "CREATED"
}
]
}
]
Now I want to filter this document basis on a condition that get all of those object
where all of the holdDetails is in RESOLVED holdStatus(ie COVERT_HOLD also in RESOLVED
holdStatus) or all of them are in RESOLVED
holdStatus except COVERT_LOCK in CREATED status
So post this condition result should be
{
"id": 1,
"holdDetails": [
{
"holdDescription": "COVERT_LOCK",
"holdStatus": "CREATED"
},
{
"holdDescription": "ALPH_LOCK",
"holdStatus": "RESOLVED"
}
]
},
{
"id": 2,
"holdDetails": [
{
"holdDescription": "ALPHA_LOCK",
"holdStatus": "RESOLVED"
},
{
"holdDescription": "BETA_LOCK",
"holdStatus": "RESOLVED"
}
]
}
]
What should be the Query.class object created in java to produce such result?
2
Answers
You can use
$filter
with$or
for this:See how it works on the playground example
You can try this: