Hi,
Is there any mongodb command to do updating an array of embedded documents with array of embedded documents? So supposed I have below existing document :
{
"_id" : 1,
"name" : "Bob",
"year" : 2012,
"animal_ref" : DBRef("animal", ObjectId("1")),
"array" : [{
"date" : ISODate("2012-11-11T09:00:00Z"),
"food" : 10
},
{
"date" : ISODate("2012-11-11T18:00:00Z"),
"food" : 10
}]
}
And I have a new "array" to be combined with the existing array like below :
"array" : [{
"date" : ISODate("2012-11-11T09:00:00Z"),
"food" : 15
},
{
"date" : ISODate("2012-11-11T19:00:00Z"),
"food" : 20
}]
And the result of this combining process will become like below :
{
"_id" : 1,
"name" : "Bob",
"year" : 2012,
"animal_ref" : DBRef("animal", ObjectId("1")),
"array" : [{
"date" : ISODate("2012-11-11T09:00:00Z"),
"food" : 15
},
{
"date" : ISODate("2012-11-11T18:00:00Z"),
"food" : 10
},
{
"date" : ISODate("2012-11-11T19:00:00Z"),
"food" : 20
}]
}
Thanks.