diff --git a/server.js b/server.js index fef586c..351e940 100644 --- a/server.js +++ b/server.js @@ -87,11 +87,14 @@ io.sockets.on('connection', function(socket){ leaderBoards.find().sort({timeStamp:-1}).limit(1, function(err, docs){ var parsedLb = JSON.parse(lb); - if( typeof docs[0].timeStamp != "undefined" ){ - if( parsedLb.timeStamp - docs[0].timeStamp > 600000){ - leaderBoards.insert(parsedLb); - console.log("Saving stats report."); - } + if( typeof docs[0] != "undefined" ){ + if(typeof docs[0].timeStamp != "undefined"){ + + if( parsedLb.timeStamp - docs[0].timeStamp > 600000){ + leaderBoards.insert(parsedLb); + console.log("Saving stats report."); + } + } } }); //