Open sh0umik opened 5 years ago
This is similar to https://github.com/asdine/storm/issues/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
})
Is there any more direct Storm way of doing that?
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