I have data in MongoDB like below:
{
"channel" : {
"_id" : "Object ID ",
"name" : "switch",
"formats" : [
{
"_id" : "Object ID ",
"formatName" : "ISO8583-93",
"description" : "ISO Format",
"fields" : [
{
"name" : "0",
"alias" : "MTI",
"lenght" : "4",
"description" : "",
"type" : "FIXED",
"dataType" : "",
"required" : true
}
],
"messages" : [
{ "_id" : "Object ID ",
"name" : "balanceEnquiry",
"alias" : "balanceEnquiry",
"description" : "balanceEnquiry Request : Sender Bank -> MessageHub",
"messageIdentification" : "",
"messageType" : "",
"messageFormat" : "",
"fields" : [
{
"name" : "DE_0",
"alias" : "MTI",
"lenght" : "4",
"description" : "",
"type" : "FIXED",
"dataType" : ""
},
{
"name" : "DE_1",
"alias" : "Primary Bitmap",
"lenght" : "8",
"description" : "Primary Bitmap",
"type" : "BIN",
"dataType" : ""
}
]
},
{ "_id" : "Object ID ",
"name" : "fundTransfer",
"alias" : "creditTransfer",
"description" : "Funds Transfer Request : Sender Bank -> Message Hub",
"messageIdentification" : "",
"messageType" : "",
"messageFormat" : "",
"fields" : [
{
"name" : "DE_0",
"alias" : "MTI",
"lenght" : "4",
"description" : "",
"type" : "FIXED",
"dataType" : ""
},
{
"name" : "DE_1",
"alias" : "Primary Bitmap",
"lenght" : "8",
"description" : "Primary Bitmap",
"type" : "BIN",
"dataType" : ""
}
]
}
]
},
{ "_id" : "Object ID ",
"formatName" : "ISO20022",
"description" : "",
"fields" : [
{
"name" : "0",
"alias" : "MTI",
"lenght" : "4",
"description" : "",
"type" : "FIXED",
"dataType" : "",
"required" : true
},
{
"name" : "1",
"alias" : "Bitmap(s)",
"lenght" : "8",
"description" : "",
"type" : "BIN",
"dataType" : "",
"required" : true
}
]
}
]
}
}
I want to update element of array “messages” by its “_id”. Depending on given condition where “channel.name”:“switch” and “channel.formats.formatName”:“ISO8583-93” and “channel.formats.messages._id”:“Object Id" of balance enquiry ”. I want to update only below part,I dont want to update field only…want to replace complete object of mongodb through java
{
"_id" : "Object ID ",
"name" : "balanceEnquiry",
"alias" : "balanceEnquiry update",
"description" : "balanceEnquiry Request : Sender Bank -> MessageHub",
"messageIdentification" : "",
"messageType" : "",
"messageFormat" : "",
"fields" : [
{
"name" : "DE_0",
"alias" : "MTI",
"lenght" : "4",
"description" : "",
"type" : "FIXED",
"dataType" : "text"
},
{
"name" : "DE_1",
"alias" : "Primary Bitmap",
"lenght" : "8",
"description" : "Primary Bitmap",
"type" : "BIN",
"dataType" : ""
}
]
}
How do I update this from Java?