Skip to content

proposal: should node expose a persistent KV API #49663

Closed
@cjihrig

Description

@cjihrig

What is the problem this feature will solve?

Embedding sqlite in Node was proposed in 2019. There was not a lot of enthusiasm at the time. It's now been over four years, and since then at least three other runtimes have emerged with some functionality like this:

  • Deno embeds sqlite and uses it to power their KV API. In the cloud they keep the same KV API, but use FoundationDB instead of sqlite.
  • Bun embeds sqlite and exposes it as their bun:sqlite API.
  • Cloudflare Workers exposes their own KV API.

What is the feature you are proposing to solve the problem?

Embedding sqlite in the binary and providing an API similar to Deno KV or Bun's sqlite module.

Using the SQLite Amalgamation makes the embedding pretty simple. On my machine, embedding sqlite with a bare bones binding caused the binary size to increase from 93.45MB to 94.82MB (at commit dac5f29).

Other outstanding questions:

  • Does sqlite compile on all of Node's supported platforms? If not, there are also wasm builds available, though I would prefer native.
  • What would the public API looks like? Deno's KV does a better job at abstracting away sqlite because they swap out underlying databases in the cloud. Bun provides a more powerful SQL interface, but that also has a better chance of becoming a leaky abstraction.

What alternatives have you considered?

Status quo. Continue using better-sqlite3, sqlite3, etc. modules from npm.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues that request new features to be added to Node.js.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions