Collection#find_first uses :limit => 1
This commit is contained in:
parent
5aa7202a78
commit
05aafc0de4
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue