Hi i need help in MONGO DB Query below is my sample object:
"_id" : ObjectId("59310db171043e6154e89a49"),
"_class" : "com.Company",
"prospectid" : "1495715281281",
"prospectemailid" : "aaa@plash.in",
"useremail" : "xyx@xyx.com",
"campaignlist" : [
{
"campaignid" : "1497813578341",
"subject" : "Camp",
"messagelist" : [
{
"timestamp" : "2017-06-02 12:33:13",
"from" : "abc@abc.com",
"to" : "xyz@xyz.in",
"body" : "<div><!--block-->Please reply to this mail.<br><br>I Look forward to<a href=\"https:div><div><!--block-->The most telling public commen" src=\5281281/1496453915668/1495398618921\" alt=\"\" style=\"width:1px;height:1px;\"/>",
"labelid" : "SEND",
"emailuniqueid" : "1496453915668",
"messageid" : "",
"messageid_tp" : "1495398618921",
"cc" : ""
}
]
},
I have to add a new object inside messagelist based on some criteria i.e useremailid,prospectemailid and campaignid.
Below is my query:
Query query = new Query(Criteria.where("useremail")
.is(useremailid)
.and("prospectemailid")
.is(prospectemailid)
.and("campaignlist.campaignid")
.is(campaignid));
update.push("campaignlist.$.messagelist", om); //om is the object of messageList
mongoTemplate.updateFirst(query, update, OtherEmailData.class);
But sometimes the object get inserted inside message list sometimes does not> I am unble to figure out why it is happening. Please Help.
I am using SpringBoot.