-
Notifications
You must be signed in to change notification settings - Fork 20
/
registry.js
54 lines (39 loc) · 930 Bytes
/
registry.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
var connections = {};
var collections = {};
var dbs = {};
/// connections
exports.connection = connection;
function connection(name, connection) {
if (! connection) return getConnection(name);
else return setConnection(name, connection);
}
function setConnection(name, connection) {
connections[name] = connection;
}
function getConnection(name) {
return connections[name];
}
/// collection
exports.collection = collection;
function collection(name, collection) {
if (! collection) return getCollection(name);
else return setCollection(name, collection);
}
function setCollection(name, collection) {
collections[name] = collection;
}
function getCollection(name) {
return collections[name];
}
/// dbs
exports.db = db;
function db(name, db) {
if (! db) return getDb(name);
else return setDb(name, db);
}
function setDb(name, db) {
dbs[name] = db;
}
function getDb(name) {
return dbs[name];
}