Support different valueEncodings per prefix
See original GitHub issueWas talking about this on IRC. Currently the valueEncoding is global per DB, making it hard to put different data types in the same hyperdb (e.g. both protobuf encoded hyperdrive stats and additional json metadata). While the valueEncoding can be a custom function, it gets only the value to be encoded/decoded, not the key.
I propose to allow optionally passing in multiple valueEncodings, keyed by prefix. That would allow different datatypes per prefix, making something like sublevel for hyperdb really simple.
Background is to allow storing additional metadata in a hyperdrive hyperdb (that does not have to fit into the hyperdrive stat protobufs). For that to work really cleanly I’d propose that hyperdrive prefixes all keys with e.g. @hd/
so that the hyperdb would be namespaced by default. This could also be optional if we’d have something like a global configuration key (does hyperdrive have this currently?) - which could also be useful for something like API or protocol version, should that ever change again.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top GitHub Comments
That actually turned out easier than I first thought.
https://github.com/Frando/subhyperdb
Not all of hyperdb API is supported yet.
Oh sorry no I meant your own layer atop hyperdb. So you’d have your own ‘put’ method that can figure out the codec to use based on key.