【发布时间】:2013-01-06 21:57:46
【问题描述】:
我有这个代码来更新一个条目:
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,
});
因为我使用的是python ddp客户端,需要这样。
问题是 nextElement 并没有真正增加我列表中的序列。想象一下,我的列表是 [50,100,150,...],如果我调用 updateList,它会变成 [50,100,150,150,150,150...] 等等……它应该变成 [50,100,150,200,250,300...]。
有人知道为什么吗?
【问题讨论】:
-
如果你想+1,为什么要+50?
-
这是我代码中其他地方的错误。对不起各位,谢谢你们的回答
标签: javascript node.js mongodb meteor