Boltdb and nested buckets

Hi all!

How do I retrieve a bucket with an unknown name in Boltdb? Say, I have a music library database, top-level buckets are artists, each of them nest album buckets, each album buckets has several key/values, key being track number, and value being JSON formatted track properties. How do I retrieve the first track of the first album of a particular artist? or for that matter, any track of any album

You iterate over the bucket contents using a cursor. That gives you both values (value is non-nil) and buckets (value is nil).

1 Like

Oh, thank you! Now I get it, artist.Cursor().First() returns k the name of the album bucket and some nil value v, and and now I can just do artist.Bucket(k).Cursor().First() which yields the first track

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.