My Collection
> db.rec1.find().pretty()
{
"_id" : ObjectId("537b4d79f8b58b56f86d0af8"),
"carrierCode" : "AA",
"carrierName" : "Americal Airline Inc",
"timing" : [
{
"arrival" : {
"date" : 200514,
"time" : 1628
}
},
{
"depart" : {
"date" : 200514,
"time" : 2000
}
}
]
}
I want to change the value of depart time to 1800. For this I am using following :
db.rec1.update({"carrierCode":"AA","timing.depart.time":2000},{$set:{"timing.$.depart":{"time":1800}}})
But this query give me undesired result.
> db.rec1.find().pretty()
{
"_id" : ObjectId("537b4d79f8b58b56f86d0af8"),
"carrierCode" : "AA",
"carrierName" : "Americal Airline Inc",
"timing" : [
{
"arrival" : {
"date" : 200514,
"time" : 1628
}
},
{
"depart" : {
"time" : 1800
}
}
]
}
In this collection, depart time is change. But this remove the date field. Please help me guys.
Just now i completed m101j mongoDB course doing some practice work for a project.
Thanks in advance.