Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var mysql = require('mysql');
- var loki = require("lokijs");
- var db = new loki('config/config.json', {
- autoload: true,
- autoloadCallback: databaseInitialize,
- autosave: true,
- autosaveInterval: 1000 // save every four seconds for our example
- });
- function databaseInitialize() {
- // on the first load of (non-existent database), we will have no collections so we can
- // detect the absence of our collections and add (and configure) them now.
- var CurConnection = db.getCollection("CurConnection");
- if (CurConnection === null) {
- CurConnection = db.addCollection("CurConnection");
- }
- }
- var CurConnection = db.getCollection("CurConnection");
- var rows = CurConnection.find({
- '$loki': {
- '$eq': 1
- }
- });
- var row = rows[0];
- var servername = row.selservername;
- var port = row.selport;
- var dbname = row.seldbname;
- var username = row.selusername;
- var password = row.selpassword;
- var connection = mysql.createPool({
- multipleStatements: true,
- host: servername,
- port: port,
- user: username,
- password: password,
- database: dbname
- });
- module.exports = connection;
Add Comment
Please, Sign In to add comment