Mikael's blog

A developers sixth time trying to maintain a blog

Source Code - Root / databaseManager.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/*****************************************
 *   Database Manager
 *****************************************
 *   Author:  mikael.lofjard@gmail.com
 *   Website: http://lofjard.se
 *   License: MIT License
 ****************************************/
 
var DatabaseManager = (function () {
 
  var cradle = require('cradle');
 
  var env = require('./environmentManager').EnvironmentManager;
  var misc = require('./misc').Misc;
   
  return {
 
    init: function (dbConfig) {
      console.log("DatabaseManager: Connecting to database");
      var db = new(cradle.Connection)(dbConfig.host, dbConfig.port).database(dbConfig.database);
      return db;
    }
  };
}());
 
typeof(exports) != 'undefined' ? exports.DatabaseManager = DatabaseManager : null;