From 075c2cb56da672656ed566a0bb1b5c7857f1696a Mon Sep 17 00:00:00 2001 From: Mathias Buus Date: Wed, 22 Jun 2011 20:30:30 +0200 Subject: [PATCH] added proxy support --- index.js | 11 +++++++++++ package.json | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index d891353..f181aaa 100644 --- a/index.js +++ b/index.js @@ -251,5 +251,16 @@ exports.connect = function(url, collections) { that[col] = that.collection(col); }); + if (typeof Proxy !== undefined) { + return Proxy.create({ + get: function(proxy, name) { + if (!that[name]) { + that[name] = that.collection(name); + } + return that[name]; + } + }); + } + return that; }; \ No newline at end of file diff --git a/package.json b/package.json index f216d7d..705076b 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,11 @@ { "name":"mongojs", "description":"a simple mongo module that emulates the mongo api", - "version":"0.1.0", + "version":"0.1.1", "author": "Ge.tt ", "contributors": [ "Mathias Buus Madsen " - ] + ], "main":"./index.js", "dependencies": {"common":">=0.1.0", "mongodb":">=0.8.0"} }