Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't edit byte'd integers #37

Closed
utdrmac opened this issue Oct 20, 2019 · 2 comments
Closed

can't edit byte'd integers #37

utdrmac opened this issue Oct 20, 2019 · 2 comments

Comments

@utdrmac
Copy link

utdrmac commented Oct 20, 2019

The value of 59629 is saved/encoded using the following:

tx.Bucket([]byte("config")).Put([]byte("lastBlockLevel"), inttob(blockLevel))

// itob returns an 8-byte big endian representation of v.
func itob(v int64) []byte {
	b := make([]byte, 8)
	binary.BigEndian.PutUint64(b, uint64(v))
	return b
}

Displays correctly when viewing bucket/kv, but attempting to edit doesn't work.

Screen Shot 2019-10-19 at 9 53 48 PM

Am I storing integers correctly or is there a better way?

@br0xen
Copy link
Owner

br0xen commented Oct 21, 2019

You're storing your integers in a fine way. The problem stems from bolt being a type-less database, so there is no built-in way to determine what the "appropriate" data type is for any value stored in it.

This means the application that is interacting with the database is in charge of encoding/decoding the bytes stored in the db. Boltbrowser is, at this point, basically just built to be able to edit string data...

I believe that, in order to resolve this issue, bb needs to have a new workflow added where you can tell it what type of data you are viewing at any given key... Then any edit on that field should be able to encode it correctly. This will probably be a decent amount of work.

@utdrmac
Copy link
Author

utdrmac commented Oct 21, 2019

Thanks for the reassurance that I'm doing things "correctly". 😄
I'll close this out then as this was really just a one-time notice sort of thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants