2015-12-11 04:11:52 +00:00
|
|
|
exports.setup = function() {
|
|
|
|
var sqlite = require('sqlite3');
|
2015-12-11 04:06:27 +00:00
|
|
|
|
2015-12-11 04:11:52 +00:00
|
|
|
var db = new sqlite.Database('database.sql');
|
2015-12-11 04:06:27 +00:00
|
|
|
|
|
|
|
db.serialize(function() {
|
2015-12-11 04:25:24 +00:00
|
|
|
db.run('CREATE TABLE IF NOT EXISTS pings (timestamp BIGINT NOT NULL, ip TINYTEXT, playerCount MEDIUMINT)');
|
2015-12-11 04:06:27 +00:00
|
|
|
});
|
2015-12-11 04:11:52 +00:00
|
|
|
|
|
|
|
exports.log = function(ip, timestamp, playerCount) {
|
2015-12-11 04:25:24 +00:00
|
|
|
var insertStatement = db.prepare('INSERT INTO pings (timestamp, ip, playerCount) VALUES (?, ?, ?)');
|
2015-12-11 04:11:52 +00:00
|
|
|
|
|
|
|
insertStatement.run(timestamp, ip, playerCount);
|
|
|
|
};
|
2015-12-11 04:06:27 +00:00
|
|
|
};
|