mafintosh / mafintosh/hyperdb

Support different valueEncodings per prefix

Open
#88 6 comments 0 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.