I am having a complex Json data and want to do MongoDB Query using MongoRepository
{
"_id":100,
"uid":"uniqueId100",
"data": [
{
"key1": "Student1",
"isValid": false,
"testData": [
{
"resultData1": "Absent",
"resultData2": null
},
{
"resultData1": "Present",
"resultData2": "Completed"
}
]
},
{
"kay1": "Student2",
"isValid": true,
"testData": [
{
"resultData1": "Present",
"resultData2": "Completed"
}
]
}
]}
Here I want to fetch data where uid=uniqueId100 and isValid=true
So this should return:
{
"_id":100,
"uid":"uniqueId100",
"data": [
{
"kay1": "Student2",
"isValid": true,
"testData": [
{
"resultData1": "Present",
"resultData2": "Completed"
}
]
}
]}
I am using SpringBoot with MongoDB as a database, I am new to this so not sure the way to do this, any suggestion and guidence will be very helpful
MongoDB has a lot of queries to find and aggregate data. You just have to write queries in model and it will return your desired result in the form of array.
As you want to fetch data and validate it, find query with the help of $match command will help you for sure.
Please refer the attached links - https://www.mongodb.com/docs/manual/reference/method/db.collection.find/#projection