1 | 'use strict';
|
2 |
|
3 | const NeDbClient = require('./clients/nedbclient');
|
4 | const MongoClient = require('./clients/mongoclient');
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | exports.connect = function(url, options) {
|
14 | if (url.indexOf('nedb://') > -1) {
|
15 |
|
16 | return NeDbClient.connect(url, options).then(function(db) {
|
17 | global.CLIENT = db;
|
18 | return db;
|
19 | });
|
20 | } else if(url.indexOf('mongodb://') > -1) {
|
21 |
|
22 | return MongoClient.connect(url, options).then(function(db) {
|
23 | global.CLIENT = db;
|
24 | return db;
|
25 | });
|
26 | } else {
|
27 | return Promise.reject(new Error('Unrecognized DB connection url.'));
|
28 | }
|
29 | }; |
\ | No newline at end of file |