Meteor.methods() unexpected behaviour when using $push and db.update

I have this code to update an entry:

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}});
}

and I call it from:

Meteor.methods({
  updateList: updateList,
});

becouse I'm using a python ddp client and needs to be this way.

The problem is that nextElement doesn't really increment the sequence on my list. Imagine that my list was [50,100,150,...], if I call updateList, it becomes [50,100,150,150,150,150...] and so on... And it's supposed to become [50,100,150,200,250,300...].

Does anyone knows why?

Let's start by making nextElement +1 instead of +50.

var nextElement = (firstList[firstList.length-1] + 1);

Note that listTime will become the last element in the list. So if you run updateList(20) the list will become [1, 2, 3, 4, 5, 6, 7, 20]. If you then call updateList(2) it will become [1, 2, 3, 4, 5, 6, 7, 20, 21, 2] and so on.

I'm not sure what listTime is supposed to do but if you wish to add last int + 1 to the list:

function updateList() {
    var firstList = Project.find().fetch()[0].list;
    var nextElement = (firstList[firstList.length-1] + 1);

    Project.update({name: "List 1"}, {$push: {list: nextElement}});
}

This will result in:

Project.find().fetch()[0].list
> [1, 2, 3, 4, 5, 6, 7]

updateList()
Project.find().fetch()[0].list
> [1, 2, 3, 4, 5, 6, 7, 8]

updateList()
Project.find().fetch()[0].list
> [1, 2, 3, 4, 5, 6, 7, 8, 9]