From 05aafc0de4c6619f7ea0fc26b7c284507dd3956b Mon Sep 17 00:00:00 2001 From: Jim Menard Date: Tue, 10 Feb 2009 13:08:15 -0500 Subject: [PATCH] Collection#find_first uses :limit => 1 --- lib/mongo/collection.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/mongo/collection.rb b/lib/mongo/collection.rb index d0b3ca4..b96eb3e 100644 --- a/lib/mongo/collection.rb +++ b/lib/mongo/collection.rb @@ -67,10 +67,10 @@ module XGen # Find the first record that matches +selector+. See #find. def find_first(selector={}, options={}) - cursor = find(selector, options) - obj = cursor.next_object - cursor.close - obj + h = options.dup + h[:limit] = 1 + cursor = find(selector, h) + cursor.next_object # don't need to explicitly close b/c of limit end # Insert +objects+, which are hashes. "<<" is aliased to this method.