lib/mongodb: collections do not call next when returning only one element
authorAlexandre Terrasa <alexandre@moz-code.org>
Wed, 24 Jun 2015 23:06:24 +0000 (19:06 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Fri, 16 Oct 2015 15:12:17 +0000 (11:12 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

lib/mongodb/mongodb.nit

index 1e9b9bd..416e36b 100644 (file)
@@ -604,10 +604,7 @@ class MongoCollection
                assert is_alive # FIXME used to avoid segfault (so `self` isn't garbage collected to soon)
                if c == null then return null
                var cursor = new MongoCursor(c)
-               if cursor.is_ok then
-                       cursor.next
-                       return cursor.item
-               end
+               if cursor.is_ok then return cursor.item
                return null
        end