Lightweight eventually consistent key/value database.
$ npm install pocdb
const pocdb = require("pocdb")
const configuration = { path: "./data", address: "127.0.0.1, port: 8000 }
pocdb.start(configuration)
pocdb.put("key", "value")
pocdb.get("key")
pocdb.destroy("key")
A backup is named after the data path, suffixed with a current timestamp generated during the call.
pocdb.backup()
pocdb.stop()
$ npm install -g pocdb
pocdb --path=./data.json --address=127.0.0.1 --port=2222
Configuration of pocdb is made up of the following properties :
The path of the pocdb persisted data.
The listening address of pocdb http server ( default 127.0.0.1 )
The listening port of pocdb http server ( default 2222 )
At pocdb start an http server is also started at the configured address and port to provide CRUD access to pocdb data.
Data explorer web interface is available under reserved path "/_explorer"
The web interface is a fork of project "react-json-editor". Original project page at https://github.com/sujinleeme/react-json-editor
Database HTTP access is available under reserved path "/_database"
For any database access HTTP request, the request subpath will be translated into a specific db key, starting after "/_database/" root path. Any "/" will be converted as an internal key separator in the data tree structure. For example an HTTP request ( GET / PUT / DELETE ) sent at "/_database/users/1" path will be internally processed as an equivalent CRUD operation on "users.1" key in the database.
Note : Root path "/_database" PUT and DELETE requests won't update the database whereas GET request will fetch the whole database.
Put a value at a specific key
PUT / POST
{ "value": <ANY_VALUE> }
{ "statusCode": 200, "message": "key updated" }
Read a value at a specific key
GET
{ "statusCode": 200, "value": <ANY_VALUE> }
Delete a value at a specific key
DELETE
{ "statusCode": 200, "message": "key destroyed" }
Data synchronisation is supported accross several instances of pocdb referencing the same persisted data file. A .pocdb log file is saved under the same location than the persisted data file. Real-time updates to .pocdb log file are performed to achieve synchronization accross any number of pocdb instances referencing the data file. Synchronization time is of 1 second, meaning eventual consistency for pocdb is reached after 1 second at most.
MIT