-
Notifications
You must be signed in to change notification settings - Fork 2
/
registry.js
62 lines (46 loc) · 1.14 KB
/
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
55
56
57
58
59
60
61
62
var connections = {};
var collections = {};
var dbs = {};
var ottoman = require('ottoman');
var couchbase = require('couchbase');
exports.connect = function (opts) {
var cluster = new couchbase.Cluster('couchbase://127.0.0.1');
var bucket = cluster.openBucket('default');
return bucket;
}
/// 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];
}