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. # Find the first record that matches +selector+. See #find.
def find_first(selector={}, options={}) def find_first(selector={}, options={})
cursor = find(selector, options) h = options.dup
obj = cursor.next_object h[:limit] = 1
cursor.close cursor = find(selector, h)
obj cursor.next_object # don't need to explicitly close b/c of limit
end end
# Insert +objects+, which are hashes. "<<" is aliased to this method. # Insert +objects+, which are hashes. "<<" is aliased to this method.