Don't load full query results in findOne()

This commit is contained in:
Avital Oliver
2013-07-09 15:40:31 -07:00
parent af12337dbb
commit 4e0d656e5c
3 changed files with 7 additions and 2 deletions

View File

@@ -1,6 +1,9 @@
## vNEXT
* Calling `findOne()` on the server no longer loads the full query result
into memory.
* Fix Spark memory leak. #1157
* Upgraded dependencies:

View File

@@ -655,7 +655,8 @@ disable this behavior, pass `{reactive: false}` as an option to
{{> api_box findone}}
Equivalent to `find(selector, options).fetch()[0]`.
Equivalent to `find(selector, options).fetch()[0]` with
`options.limit = 1`.
{{> api_box insert}}

View File

@@ -288,7 +288,8 @@ _Mongo.prototype.findOne = function (collection_name, selector, options) {
if (arguments.length === 1)
selector = {};
// XXX use limit=1 instead?
options = options || {};
options.limit = 1;
return self.find(collection_name, selector, options).fetch()[0];
};