76
rated 0 times
[
81]
[
5]
/ answers: 1 / hits: 16874
/ 10 Years ago, thu, february 20, 2014, 12:00:00
Polls.update({_id: id}, {$set : {already_voted[length]: ip});
Now this obviously doesn't work. I can't simply put a variable length in there.
Basically I have already_voted
which is an array and I want to add a new ip to this array. The way I handle this currently is by getting the old length and using the old length as the new index to add the element.
I am wondering how I should go about doing this as my current setup does not work.
To clarify : I don't have the whole array, I just want to add a new element into the array in the Poll document.
More From » arrays