1 | var MongoClient = require('mongodb').MongoClient;
|
2 |
|
3 | exports.addConnection = function (connection, app, callback) {
|
4 | if(!app.locals.dbConnections){
|
5 | app.locals.dbConnections = [];
|
6 | }
|
7 |
|
8 | MongoClient.connect(connection.connString, function(err, database) {
|
9 | if(err){
|
10 | callback(err, null);
|
11 | }else{
|
12 | var dbObj = {};
|
13 | dbObj.native = database;
|
14 | dbObj.connString = connection.connString;
|
15 |
|
16 | app.locals.dbConnections[connection.connName] = null;
|
17 | app.locals.dbConnections[connection.connName] = dbObj;
|
18 | callback(null, null);
|
19 | }
|
20 | });
|
21 | }; |
\ | No newline at end of file |