3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-27 14:29:29 +01:00
dbot/database.js

29 lines
780 B
JavaScript

var databank = require('databank'),
Databank = databank.Databank,
DatabankObject = databank.DatabankObject;
//DatabankStore = require('connect-databank')(express);
/**
* Multiplex databank objects
*/
var DatabaseDriver = function() {
this.databanks = {};
};
/**
* Connect to or create a new DataBank
*/
DatabaseDriver.prototype.createDB = function(name, driver, callback, schema) {
var params = { 'schema': schema };
this.databanks[name] = Databank.get(driver, params);
this.databanks[name].connect({}, function(err) {
if(err) {
console.log('Didn\'t manage to connect to the data source.');
} else {
callback(this.databanks[name]);
}
}.bind(this));
};
exports.DatabaseDriver = DatabaseDriver;