-
Type: Bug
-
Resolution: Won't Fix
-
Priority: Minor - P4
-
Affects Version/s: None
-
Component/s: None
-
Labels:None
If you have a collection, "test" containing 3 documents.
test = db.collection('test')
test.insert(
)
test.insert(
)
test.insert(
)
cursor = test.find
puts cursor.count
- => 3
puts cursor.first
- => { '_id' => ..., 'a' => 1}
cursor.each do |doc|
puts doc
end
- => { '_id' => ..., 'b' => 1 }
- => { '_id' => ..., 'c' => 1 }
I would expect the call to #first to be non-destructive so that a later iteration returns all 3 documents.
A possible to workaround is to use each_with_index and checking if the index == 0