Skip to content

Commit

Permalink
Collection.find now takes all the arguments into account.
Browse files Browse the repository at this point in the history
  • Loading branch information
sergi committed Nov 1, 2009
1 parent b5685ae commit aa0acd5
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/mongodb.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,14 @@ Collection.prototype = {
this.collection.dropIndexes();
this.collection.drop();
},
find: function(obj) {
var dbo = Util.createBDObject(obj);
return new Cursor(this.collection.find(dbo));
find: function() {
var args = Array.prototype.slice.call(arguments)
.map(function(arg) {
return typeof arg == "object" ?
Util.createBDObject(arg) : arg;
});

return new Cursor(this.collection.find.apply(this.collection, args));
},
findOne: function(obj) {
var dbo = obj;
Expand All @@ -158,7 +163,7 @@ Collection.prototype = {

var sm = this.collection.findOne(Util.createBDObject(dbo), Util.createBDObject(arguments[1]));
if (sm) {
var jsObj = { __proto__: null},
var jsObj = {__proto__: null},
smKeySet = sm.keySet().toArray();
for each(var i in smKeySet)
jsObj[i] = sm.get(i);
Expand Down

0 comments on commit aa0acd5

Please sign in to comment.