You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
713 B
32 lines
713 B
const mysql = require("mysql");
|
|
const fs = require("fs");
|
|
|
|
const state = {
|
|
pool: null
|
|
};
|
|
|
|
exports.connect = function(done){
|
|
state.pool = mysql.createPool({
|
|
host: 'localhost',
|
|
user: 'root',
|
|
password: 'root',
|
|
port: 3306,
|
|
database: "territory-walker",
|
|
//multipleStatements: true
|
|
});
|
|
done();
|
|
};
|
|
|
|
exports.get = function(){
|
|
return state.pool;
|
|
};
|
|
|
|
exports.addTables = function(done) {
|
|
fs.readFile('res/database_setup.sql', 'utf-8', function(err, result){
|
|
if(err) return done(err);
|
|
state.pool.query(result, function(err, result) {
|
|
if (err) return done(err);
|
|
return done(false, result);
|
|
});
|
|
});
|
|
}; |