Minetrack/lib/database.js

15 lines
470 B
JavaScript
Raw Normal View History

exports.setup = function() {
var sqlite = require('sqlite3');
2015-12-11 04:06:27 +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
});
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 (?, ?, ?)');
insertStatement.run(timestamp, ip, playerCount);
};
2015-12-11 04:06:27 +00:00
};