Created
September 22, 2011 20:07
-
-
Save joshkehn/1235880 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> db.users.findOne | |
function (query, fields) { | |
var cursor = this._mongo.find(this._fullName, this._massageObject(query) || {}, fields, -1, 0, 0, 0); | |
if (!cursor.hasNext()) { | |
return null; | |
} | |
var ret = cursor.next(); | |
if (cursor.hasNext()) { | |
throw "findOne has more than 1 result!"; | |
} | |
if (ret.$err) { | |
throw "error " + tojson(ret); | |
} | |
return ret; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment