/immutabledb

Interface for content-addressed storage as a database

Primary LanguageJavaScriptMIT LicenseMIT

ImmutableDB

ImmutableDB is an interface for content-addressed storage systems as databases.

Table of Contents

Specification

ImmutableDB is specified as:

  1. same data always returns the same key (write)
  2. same key always returns the same data (read)

The difference to traditional relational databases, document databases or key-value stores is that the key doesn't get specified explicitly by the user. Instead, the key gets calculated based on the data using a hashing function. This is also called content-addressed storage.

In practice this means that saving hello world to an ImmutableDB will always return key abc regardless of which instance or location the data is saved at and saving hello world! will return cba. In turn, querying the value of key abc will always return hello world, regardless of instance and location.

Interface

put (value)

Save value to database and return a key.

Example:

var key = put("hello world")
console.log(key)
// "abc"

get (key)

Retrieve the value of key from the database.

Example:

var data = get("abc")
console.log(data)
// "hello world"

Implementations

ImmutableDB can be used via the following implementations:

Contribute

New backend implementations, PRs and discussion are gladly accepted!

License

MIT © 2017 Haad