path-store

0.0.3 • Public • Published

Path-Store

A Key Value store with support for multiple backends

Path-Store is still in early development.

What is it

Path-Store is a key value store that makes use of paths in order to pull data from multiple backends. For instance, to query a Firebase instance you might use the path /root/firebase/path/to/value. Backends can easily be implemented using a simple API.

The idea is be able to cache your data across a series of different Backends. For instance, you might have an in-memory Backend that syncs to an IndexDB Backend. The in-memory Backend can act as a cache over the IndexDB Backend. Furthermore, the IndexDB Backend could sync to a remote Postgres instance, with the IndexDB Backend acting as a cache over the remote database. In this way, very large datasets can be easily manipulated without downloading the entire set, and a variety of databases can be coordinated.

A Simple Backend Example:

In theory, Path-Store can be used as a simple wrapper around a set of functions that communicated with a remote database (a Backend). Nothing is cached, and each query to Path-Store is really just a query to the database.

A Better Backend Example:

A better use case would combine a remote database Backend with an in-memory Backend. The in-memory Backend would cache all calls to the remote database, and the size of the cache can be easily controlled.

How does it work

Path-Store maintains an internal graph representation of your data. Each Node on the graph contains a value and map of paths to other nodes. When queried, Path-Store uses a given path to find the appropriate Node.

The Paths

A path can be represeted as an array of strings. The path /root/firebase/path/to/value would, for instance, be represented like so: ["root", "firebase", "path", "to", "value"].

This looks like a sort ofmap of maps. Each item in the path array is a key to a map on a Node. Each item in the path array is a key to the map in which to find the next Node. In our example, the root Node must have the key "firebase" in its map, and it's value must be a different Node with a map containing the key "path", and so on. The value returned from querying with this path with the the final Node's value property.

Backend

A Path-Store Backend is an easily implemented API plus a cache.

Readme

Keywords

none

Package Sidebar

Install

npm i path-store

Weekly Downloads

0

Version

0.0.3

License

ISC

Last publish

Collaborators

  • sballan