From 6e14367855d9c12ad950130aaf65e553edd1351f Mon Sep 17 00:00:00 2001 From: edoardoo Date: Sun, 9 Aug 2015 21:55:19 +0200 Subject: [PATCH] fix: insert first leaderboard data --- server.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index e69c55e..34298cd 100644 --- a/server.js +++ b/server.js @@ -87,7 +87,7 @@ 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] != "undefined" ){ + if( docs.length ){ if(typeof docs[0].timeStamp != "undefined"){ if( parsedLb.timeStamp - docs[0].timeStamp > 600000){ @@ -99,6 +99,9 @@ io.sockets.on('connection', function(socket){ leaderBoards.insert(parsedLb); } + if(err){ + console.dir(err); + } }); //