我有這樣的代碼來更新條目時:
function updateList(listTime) {
var firstList = Project.find().fetch()[0].list; // returns a list
var nextElement = (firstList[firstList.length-1] + 50); // value of last + 50
Project.update({name: "List 1"}, {$push: {list: nextElement}});
}
,我把它從:
Meteor.methods({
updateList: updateList,
});
becouse我m使用Python的ddp客戶端,需要這樣。
問題是nextElement並沒有真正增加我列表上的序列。想象一下,我的列表是[50,100,150,...],如果我調用updateList,它會變成[50,100,150,150,150,150 ...]等等......它應該變成[50,100,150,200,250,300 ...]。
有誰知道爲什麼?
你爲什麼+50如果你想要+1嗎? –
這是我的代碼中的其他地方的錯誤。對不起,夥計,並感謝您的答案 – jdscosta91