Skip to content

Commit

Permalink
Merge pull request #67 from Osterjour/patch-1
Browse files Browse the repository at this point in the history
Fixing problems with collections which have the same name as functions
  • Loading branch information
mafintosh committed Jul 25, 2013
2 parents ac10c44 + 3567157 commit e7ed5ff
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ Database.prototype.runCommand = function(opts, callback) {

Database.prototype.collection = function(name) {
var self = this;
if (this[name]) return this[name];

var oncollection = thunky(function(callback) {
self._get(function(err, db) {
Expand All @@ -251,7 +250,7 @@ Database.prototype.collection = function(name) {
});
});

return this[name] = new Collection(oncollection);
return new Collection(oncollection);
};

forEachMethod(DRIVER_DB_PROTO, Database.prototype, function(methodName, fn) {
Expand Down Expand Up @@ -282,7 +281,7 @@ var connect = function(config, collections) {

collections = collections || config.collections || [];
collections.forEach(function(colName) {
that.collection(colName);
that[colName] = that.collection(colName);
});

return that;
Expand Down

0 comments on commit e7ed5ff

Please sign in to comment.