Support different valueEncodings per prefix
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 748
- Forks
- 56
- PR merge metrics
- No merged PRs in 30d
Description
Was 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](https://github.com/dominictarr/level-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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the current database valueEncoding interface and how keys are passed to encoding and decoding. Compare the proposed prefix-keyed encodings with the hyperdrive metadata use case and the suggested @hd/ namespace. Done means different prefixes can use different value encodings without breaking existing database data.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- database
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100