Permalink
Browse files

Collection.find now takes all the arguments into account.

  • Loading branch information...
1 parent b5685ae commit aa0acd5aee24a6370746c1521b579ab766d4240e @sergi committed Nov 1, 2009
Showing with 9 additions and 4 deletions.
  1. +9 −4 lib/mongodb.js
View
@@ -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;
@@ -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);

0 comments on commit aa0acd5

Please sign in to comment.