How to use spring mongo query criteria based only for below thing.
I don't want to use spring mongo save method even though its doing upsert because of application is running in multi threaded environment so only specified values should updated and remaining values will not change.
Suppose the document looks like:
{
"dept": "FY",
"companyName": "TIS",
"id":"112234",
"contacts": [{
"name": "Jeff",
"phone": "222 - 572 - 8754"
},
{
"name": "Joe",
"phone": "456 - 875 - 4521"
},
{
"name": "Alex",
"phone": "789 - 875 - 4521"
}
]
}
based on id and the array list passing to update method the contacts list should update.
Lets take based on id=112234 and passing contacts list to update method, based on contact name it should update.
"contacts": [{
"name": "Jeff",
"phone": "111 - 000 - 123"
},
{
"name": "Joe",
"phone": "980 - 546 - 0000"
}
]
the final mongo json document should updated as below:
{
"dept": "FY",
"companyName": "TIS",
"id":"112234",
"contacts": [{
"name": "Jeff",
"phone": "111 - 000 - 123"
},
{
"name": "Joe",
"phone": "980 - 546 - 0000"
},
{
"name": "Alex",
"phone": "789 - 875 - 4521"
}
]
}