-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
39 lines (32 loc) · 1.08 KB
/
index.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
'use strict';
var mongojs = require('mongojs');
var Database = require('./lib/database');
// ObjectId
module.exports = function(connString, cols, options) {
var connection = mongojs.apply(null, arguments);
var db = new Database(connection);
cols = cols || [];
cols.forEach(function(colName) {
db[colName] = db.collection(colName);
var parts = colName.split('.');
var last = parts.pop();
var parent = parts.reduce(function(parent, prefix) {
parent[prefix] = parent[prefix] || {};
return parent[prefix];
}, db);
parent[last] = db.collection(colName);
});
return db;
};
module.exports.default = module.exports;
// expose bson stuff visible in the shell
module.exports.Binary = mongojs.Binary;
module.exports.Code = mongojs.Code;
module.exports.DBRef = mongojs.DBRef;
module.exports.Double = mongojs.Double;
module.exports.Long = mongojs.Long;
module.exports.MinKey = mongojs.MinKey;
module.exports.MaxKey = mongojs.MaxKey;
module.exports.ObjectID = mongojs.ObjectID;
module.exports.Symbol = mongojs.Symbol;
module.exports.Timestamp = mongojs.Timestamp;