Badger example with prefix?


(Alan Willis) #1

I’m looking for an example of how to set and iterate over a data using prefixes. Could someone please point me in the right direction?


(Manish R Jain) #2

See: https://github.com/dgraph-io/badger#prefix-scans


(Alan Willis) #3

The prefix key used in the example casts a string as a byte array. I’m using binary.LittleEndian.PutUint64 to create byte arrays from uint64 values. I can store the data, but prefix scans don’t return any data. I didn’t want to have to use a string as a prefix key.


(Manish R Jain) #4

Someone else can probably help you better, but generally speaking, you’d use a BigEndian encoding for Uint64s so they maintain their order when sorted lexicographically.