I have the following json
"_id" : ObjectId("5fd0b6d2db14e72272560029"),
"fooId" : "",
"fooNames" : [],
"fooDetails" : [
{
"foId" : "5fd0b63ddb14e7227255fffb",
"fooSubId" : "5fd0b6d2db14e72272560029"
}
],
...
I need to pull out the results of those documents whose _id
is not equal to the nested object fooDetails.fooSubId
.
How can I do this in spring Mongo?
--UPDATE--
For example below given are the entries in my collection
Entry one
{
"_id": ObjectId("5fd0b63ddb14e7227255fff1"),
"fooId": "",
"fooNames": [],
"fooDetails": [
{
"foId": "5fd0b63ddb14e7227255fffb",
"fooSubId": "5fd0b63ddb14e7227255fff1"
},
]
}
Entry two
{
"_id": ObjectId("5fd0b63ddb14e7227255fff2"),
"fooId": "",
"fooNames": [],
"fooDetails": [
{
"foId": "5fd0b63ddb14e7227255fffb",
"fooSubId": "5fd0b63ddb14e7227255fff3",
}
]
}
Entry three
{
"_id": ObjectId("5fd0b63ddb14e7227255fff2"),
"fooId": "",
"fooNames": [],
"fooDetails": []
}
The result should filter out the first one, it should give only the following two:
Result one
{
"_id": ObjectId("5fd0b63ddb14e7227255fff2"),
"fooId": "",
"fooNames": [],
"fooDetails": [
{
"foId": "5fd0b63ddb14e7227255fffb",
"fooSubId": "5fd0b63ddb14e7227255fff3",
}
]
}
Result two
{
"_id": ObjectId("5fd0b63ddb14e7227255fff4"),
"fooId": "",
"fooNames": [],
"fooDetails": []
}