我正在使用Meteor進(jìn)行如下更新:Items.update(Session.get('selectedItem'), {'$set': {'directions.0.name': area.value}})但是我在努力如何動(dòng)態(tài)設(shè)置方向的數(shù)組索引,就像這樣:var index = //a value determined dynamicallyItems.update(Session.get('selectedItem'), {'$set': {'directions[index]name': area.value}})這不起作用,因?yàn)閇index]被包裝在字符串中。我還嘗試形成一個(gè)自定義字符串,如下所示:var string = 'directions.'+itemIndex+'.name'Items.update(Session.get('selectedItem'), {'$set': {string: area.value}})但這是行不通的。關(guān)于如何執(zhí)行此操作的任何想法?
在mongodb更新中使用變量
墨色風(fēng)雨
2019-10-30 13:03:15