We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test: `package main
import ( "fmt" "strconv" "time"
"github.com/deroproject/graviton"
)
func main() {
store, _ := graviton.NewDiskStore("db/graviton.db") //memdb, _ := graviton.NewMemStore() // temporary memory db ss, _ := store.LoadSnapshot(0) tree, _ := ss.GetTree("root") // Create a list of date and store in database fmt.Println() today := time.Now() keys := 1 for x := 0; x < 10; x++ { date := today.AddDate(0, 0, x) save := fmt.Sprintf("%02d-%02d-%04d", date.Day(), date.Month(), date.Year()) tree.Put([]byte(strconv.Itoa(keys)), []byte(save)) keys++ } graviton.Commit(tree) fmt.Println() // Get individual value based on key = "1" example var key string = "1" value, _ := tree.Get([]byte(key)) fmt.Printf("SINGLE: key=%s, value=%s\n", key, string(value)) fmt.Println() // Get first value stored in database first := tree.Cursor() k, v, _ := first.First() fmt.Printf("FIRST: key=%s, value=%s\n", k, v) fmt.Println() // Get last value stored in database last := tree.Cursor() for k, v, err := last.Last(); err == nil; k, v, err = last.Next() { fmt.Printf("LAST key=%s, value=%s\n", k, v) } fmt.Println() // Get last 5 values stored in database five := tree.Cursor() count := 5 for k, v, err := five.Last(); err == nil && count != 0; k, v, err = five.Prev() { fmt.Printf("LAST%s key=%s, value=%s\n", k, k, v) count-- } fmt.Println() // Get all values stored in database c := tree.Cursor() fmt.Println("ALL:") for k, v, err := c.First(); err == nil; k, v, err = c.Next() { fmt.Printf("key=%s, value=%s\n", k, v) } fmt.Println()
} `
The out put of ALL values + LAST 5 is incorrect Example:
LAST10 key=10, value=30-01-2023 LAST7 key=7, value=27-01-2023 LAST2 key=2, value=22-01-2023 LAST8 key=8, value=28-01-2023 LAST9 key=9, value=29-01-2023 ALL: key=1, value=21-01-2023 key=3, value=23-01-2023 key=5, value=25-01-2023 key=6, value=26-01-2023 key=4, value=24-01-2023 key=9, value=29-01-2023 key=8, value=28-01-2023 key=2, value=22-01-2023 key=7, value=27-01-2023 key=10, value=30-01-2023
Please advise how I can correct this as ORDER is very important for me.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Test:
`package main
import (
"fmt"
"strconv"
"time"
)
func main() {
}
`
The out put of ALL values + LAST 5 is incorrect
Example:
Please advise how I can correct this as ORDER is very important for me.
The text was updated successfully, but these errors were encountered: