You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is similar to #209, but I can't figure out how to do it with the .Each() method mentioned in that discussion (or a db.All()) with a very simple key:value store (string:bool).
The best I've figured out so far is to do a manual Bolt transaction. I only want the keys in my case:
// create db, do some 'db.Set("urls", urlString, true)'
var urls []string
db.Bolt.View(func(tx *bolt.Tx) error {
b := tx.Bucket([]byte("urls"))
c := b.Cursor()
for k, v := c.First(); k != nil; k, v = c.Next() {
fmt.Printf("key=%s, value=%s\n", k, v)
urls = append(urls, string(k)) //convert to string because Bolt holds it as []byte
}
return nil
})
When I use Set and Get it requires a bucket name.
But how can I get all the items in the particular bucket
logs
? How to iterate over a bucket elements ?Proposing Something like
The text was updated successfully, but these errors were encountered: