diff --git a/index.js b/index.js index 55d6478..6ae0451 100644 --- a/index.js +++ b/index.js @@ -28,6 +28,10 @@ var parse = function(options) { return result; }; +var shouldExtend = function(that, proto, name) { + if (name[0] === '_') return false; + return !that[name] && !proto.__lookupGetter__(name) && typeof proto[name] === 'function'; +}; // basicly just a proxy prototype var Cursor = function(oncursor) { @@ -146,7 +150,7 @@ Collection.prototype.disconnect = function() { }; Object.keys(mongo.Collection.prototype).forEach(function(name) { // we just wanna proxy any remaining methods on collections - if (!Collection.prototype[name] && typeof mongo.Collection.prototype[name] === 'function') { + if (shouldExtend(Collection.prototype, mongo.Collection.prototype, name)) { Collection.prototype[name] = function() { this._exec(name, arguments); }; @@ -215,7 +219,7 @@ exports.connect = function(url, collections) { }; Object.keys(mongo.Db.prototype).forEach(function(name) { - if (!that[name] && typeof mongo.Db.prototype[name] === 'function') { + if (shouldExtend(that, mongo.Db.prototype, name)) { that[name] = function() { var args = arguments; var callback = args[args.length-1] || noop; diff --git a/package.json b/package.json index 88b96ce..730da44 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name":"mongojs", "description":"a simple mongo module that implements the mongo api", "keywords": ["mongo", "db", "mongodb"], - "version":"0.3.2", + "version":"0.4.0", "homepage" : "https://github.com/gett/mongojs", "author": "Ge.tt ", "contributors": [ @@ -10,5 +10,5 @@ "Ian Jorgensen " ], "main":"./index.js", - "dependencies": {"common":">=0.1.0", "mongodb":">=0.9.6"} + "dependencies": {"common":">=0.1.0", "mongodb":"1.x.x"} }