I am making a voting system, the voting is done with a link. In my index.js I get the required values and put them in variables. The "type" variable stands for the field in my mongodb wich needs to be updated, I have put it in a variable because it depends on which link is clicked.
Now in the $set function they require the db field and a new value, for both I use variables but my "type" variable doesn't work. And when I go to my mongodb there is a new table created called "type". How can this be solved?
router.get('/vote/:Id/:Value/:Type', function(req, res) {
var db = req.db;
var id = req.params.Id;
var type = req.params.Type;
var value = parseInt(req.params.Value);
var newValue = value + 1;
var collection = db.get('games');
collection.update(
{"_id" : id},
{$set: {type: newValue}}
, function (err, doc) {
if (err) {
res.send("There was a problem");
}
else {
res.location("../../../admin");
res.redirect("../../../admin");
}
});
});