Set Meta Data to badger

Can somebody add examples?
How I can add metadata to method set to badger.
And how I can get metadata from key in db.

Does the documentation for SetWithMeta help? GitHub - dgraph-io/badger: Fast key-value DB in Go.

As well as the docstring and implementation for SetWithMeta? badger/transaction.go at ed2529abad4cd69c354144dc811206960bb4173c · dgraph-io/badger · GitHub

But meta is byte. Can I add some string data to meta?
For example, I have:
key - “string” & value - map[string]string or map[int]int (with json.Marshal)
I need to add type of map to meta (map[int]string). How I can do this?
How I can get meta from key-value pair?

What you can do is set bit fields that indicate the type of the value, e.g.,

mapStringString = 0x01
mapStringInt = 0x02

and then use those for value type checking.

1 Like