I have a requirement of storing data in mongoDB where the same data(id&version) comes again it should update and change the status to matched. While for the first time status should be pending.
Example –
When data comes for first time insert like below –
{
id:ABC
version:1
status:pending
}
When the data comes next time update like below
{
id:ABC
version:1
status:matched
}
Today we are doing get call first and comparing in java layer then updating the status. This is unnecessary two i/o for every input.
Can this be made in single call itself? Like check the condition and upsert on match.
I have tried to add filters on some fields and upsert in single call. But changing the value of status in match case is something I am not aware.
Any help will be appreciated .