This commit is contained in:
reality 2013-07-08 10:06:34 +00:00
parent 9aec9f4df4
commit 287b718b17
2 changed files with 8 additions and 5 deletions

View File

@ -1,11 +1,13 @@
var databank = require('databank'),
Databank = databank.Databank,
DatabankObject = databank.DatabankObject;
DatabankObject = databank.DatabankObject,
_ = require('underscore')._;
/**
* Multiplex databank objects
*/
var DatabaseDriver = function() {
var DatabaseDriver = function(config) {
this.config = config;
this.databanks = {};
};
@ -15,6 +17,7 @@ var DatabaseDriver = function() {
DatabaseDriver.prototype.createDB = function(name, driver, schema, callback) {
var params = { 'schema': schema };
if(driver == 'redis' && _.has(this.config, 'redisPort')) params.port = this.config.redisPort;
if(driver == 'disk') params.dir = 'db';
this.databanks[name] = Databank.get(driver, params);

6
run.js
View File

@ -18,11 +18,11 @@ var DBot = function() {
this.db = {};
}
/*** Load the fancy DB ***/
this.ddb = new DatabaseDriver();
this.reloadConfig();
/*** Load the fancy DB ***/
this.ddb = new DatabaseDriver(this.config);
/*** Load main strings ***/
try {
this.strings = JSON.parse(fs.readFileSync('strings.json', 'utf-8'));