Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed bug in findOne that occured when no arguments were passed, and …

…added methor curr() to DBCursor
  • Loading branch information...
commit 1b7e201a37868a76389ab78b2f7642977ddad633 1 parent 2eed22e
@sergi authored
Showing with 7 additions and 0 deletions.
  1. +7 −0 lib/mongodb.js
View
7 lib/mongodb.js
@@ -157,6 +157,10 @@ Collection.prototype = {
return new Cursor(this.collection.find.apply(this.collection, args));
},
findOne: function(obj) {
+ var all;
+ if (!obj && (parseInt((all = this.find()).count()) === 1))
+ return all.next();
+
var dbo = obj;
if (obj && typeof(obj) != "object")
dbo = { "_id": obj };
@@ -260,6 +264,9 @@ Cursor.prototype = {
count: function() {
return this.cursor.count();
},
+ curr: function() {
+ return this.cursor.curr();
+ },
length: function() {
return this.cursor.length();
},
Please sign in to comment.
Something went wrong with that request. Please try again.