Collection#find_first uses :limit => 1

This commit is contained in:
Jim Menard 2009-02-10 13:08:15 -05:00
parent 5aa7202a78
commit 05aafc0de4
1 changed files with 4 additions and 4 deletions

View File

@ -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.