| 43 | } |
| 44 | |
| 45 | func forwardIteration() { |
| 46 | fmt.Println("--------begin forwardIteration--------") |
| 47 | tx, err := db.Begin(false) |
| 48 | if err != nil { |
| 49 | panic(err) |
| 50 | } |
| 51 | iterator := nutsdb.NewIterator(tx, bucket, nutsdb.IteratorOptions{Reverse: false}) |
| 52 | for { |
| 53 | value, _ := iterator.Value() |
| 54 | fmt.Println("Key: ", string(iterator.Key())) |
| 55 | fmt.Println("Value: ", string(value)) |
| 56 | fmt.Println() |
| 57 | if !iterator.Next() { |
| 58 | break |
| 59 | } |
| 60 | } |
| 61 | err = tx.Commit() |
| 62 | if err != nil { |
| 63 | panic(err) |
| 64 | } |
| 65 | fmt.Println("--------end forwardIteration--------") |
| 66 | } |
| 67 | |
| 68 | func reverseIterative() { |
| 69 | fmt.Println("--------start reverseIterative--------") |