0
我正在嘗試更新數組內的對象。這裏是我的結構:基於索引更新數組流星
"_id": "ubtQP9EjmxhXS5z98",
"name": "My Data",
"desc": "What songs should I play at my wedding?",
"private": false,
"suggestions": [
{
"name": "Vote 1",
"link": "http://www.website.com/",
"votes": 0
},
{
"name": "Vote 2",
"votes": 0
}
],
"author": "tovd9Win3C3fntgyR",
"createdAt": "2016-01-10T08:36:37.014Z"
這裏是我的更新代碼:
Meteor.methods({
voteup: function(itemIndex, userId){
Polls.update({"_id": "ubtQP9EjmxhXS5z98"}, {
"$inc": {"suggestions."+itemIndex+".votes": 1}
});
}
});
這是行不通的。它只是使我的應用程序崩潰。