Commits

Liam Staskawicz committed a03d506

* Cursor.each()

Comments (0)

Files changed (2)

     return objects
   }
   
+  Void each(|Str:Obj? item, Int index| c)
+  {
+    i := 0
+    while(this.more) { c.call(this.next, i++) }
+  }
+  
   **
   ** Which query options have been selected.
   ** See http://www.mongodb.org/display/DOCS/Mongo+Wire+Protocol#MongoWireProtocol-Mongo::Constants::OPQUERY

test/CursorTest.fan

     }
     coll.drop
   }
+  
+  Void testEach()
+  {
+    coll := db["eachtest"]
+    coll.drop
+    i := 0
+    iter := 10
+    iter.times { coll.insert(["count":i++]) }
+    coll.find().each |v, c| {
+      if(v["count"] != c)
+        fail("cursor.each returned different values than expected")
+    }
+    
+    coll.drop
+  }
 
 }