Permalink
Browse files

add getters for collections that include .

closes #6
  • Loading branch information...
1 parent 3a9ce40 commit 9b3c8e12f3369b9898f5d3c51bb6554ea03b5a03 @aheckmann committed Feb 9, 2013
Showing with 15 additions and 0 deletions.
  1. +15 −0 lib/db.js
View
@@ -231,6 +231,21 @@ function createConstructor (db) {
// TODO abstract collection
names.forEach(function (name) {
self[name] = db.collection(name);
+
+ // handle system.indexes etc
+ if (/\./.test(name)) {
+ var parts = name.split('.');
+ parts.reduce(function (out, part, i) {
+ if (i == parts.length - 1) {
+ out[part] = self[name];
+ } else {
+ if (!out[part]) {
+ out[part] = {};
+ }
+ }
+ return out[part];
+ }, self);
+ }
});
if (cb) return cb(err, names);

0 comments on commit 9b3c8e1

Please sign in to comment.