I have a timer that I’m trying to use. When I run this code in a web browser it works fine but it isn’t working in the node.js server code and I can’t figure out what I’m doing wrong. Here’s my full code.
/* global Backendless /
/*
-
green timer.
-
It is executed according to the schedule
*/
Backendless.ServerCode.addTimer({name: ‘green’,
startDate: 1467256980000,
frequency: {
schedule: ‘once’
},/**
-
@param {Object} req
-
@param {String} req.context Application Version Id
*/
execute(req){
//add your code here
function Game42(args) {
args = args || {};
this.aggVotes = args.aggVotes || “”;
this.isPres = args.isPres || “”;
this.pVote1 = args.pVote1 || “”;
this.pVoteResult1 = args.pVoteResult1 || “”;
this.player = args.player || “”;
this.isElim = args.isElim || “”;}
var PAGESIZE = 100;
var offset = 0;
var query = new Backendless.DataQuery();
var queryOptions = {
condition: “isElim = false”,
pageSize: PAGESIZE
};
query.options = queryOptions;var hasValue = Backendless.Persistence.of(Game1).find(query);
if (hasValue.data[0].player == hasValue.data[1].pVote1) {
hasValue.data[0].pVoteResult1 += 1;
}if (hasValue.data[0].player == hasValue.data[2].pVote1) {
hasValue.data[0].pVoteResult1 += 1;
}if (hasValue.data[0].player == hasValue.data[3].pVote1) {
hasValue.data[0].pVoteResult1 += 1;
}if (hasValue.data[0].player == hasValue.data[4].pVote1) {
hasValue.data[0].pVoteResult1 += 1;
}if (hasValue.data[0].player == hasValue.data[5].pVote1) {
hasValue.data[0].pVoteResult1 += 1;
}if (hasValue.data[0].player == hasValue.data[6].pVote1) {
hasValue.data[0].pVoteResult1 += 1;
}if (hasValue.data[0].player == hasValue.data[7].pVote1) {
hasValue.data[0].pVoteResult1 += 1;
}if (hasValue.data[0].player == hasValue.data[8].pVote1) {
hasValue.data[0].pVoteResult1 += 1;
}if (hasValue.data[0].player == hasValue.data[9].pVote1) {
hasValue.data[0].pVoteResult1 += 1;
}if (hasValue.data[0].player == hasValue.data[10].pVote1) {
hasValue.data[0].pVoteResult1 += 1;
}hasValue.data[0].aggVotes += hasValue.data[0].pVoteResult1;
Backendless.Persistence.of(Game1).save(hasValue.data[0]);
}
}); -