Skip to content

Commit

Permalink
compatible with mongodb 1.x.x
Browse files Browse the repository at this point in the history
  • Loading branch information
mafintosh committed May 13, 2012
1 parent 69ddb6f commit df360a7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
};
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"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 <[email protected]>",
"contributors": [
"Mathias Buus Madsen <[email protected]>",
"Ian Jorgensen <[email protected]>"
],
"main":"./index.js",
"dependencies": {"common":">=0.1.0", "mongodb":">=0.9.6"}
"dependencies": {"common":">=0.1.0", "mongodb":"1.x.x"}
}

0 comments on commit df360a7

Please sign in to comment.