Database cursors, when they're first created, are in a "-1st" position. That is to say, both of the following loops will produce the same output:
for cursor.Next() { fmt.Println(cursor.Get()) }for ok := cursor.First(); ok; ok = cursor.Next() { fmt.Println(cursor.Get()) }
Unfortunately, if the cursor needs to be reused, there's no way to reset it to the "-1st" position. This opens us up to bugs.
We have the following iterators:
Database cursors, when they're first created, are in a "-1st" position. That is to say, both of the following loops will produce the same output:
for cursor.Next() { fmt.Println(cursor.Get()) }
for ok := cursor.First(); ok; ok = cursor.Next() { fmt.Println(cursor.Get()) }
Unfortunately, if the cursor needs to be reused, there's no way to reset it to the "-1st" position. This opens us up to bugs.