npm.io
1.0.8 • Published 1 month agoCLI

littledb

Licence
MIT
Version
1.0.8
Deps
0
Size
4 kB
Vulns
0
Weekly
0
Stars
5

littledb Build Status

littledb is the littlest key-value database possible based on this awesome gist.

littledb consists of simple JavaScript API to put/get and ls to/from database and simple database server.

To run server, simply install package and run

littledb 80 # without passing some available port will be chosen

or in node.js

const port = 80
require('littledb')().listen(port)

Then you can simply access it with curl:

# save key
curl -d "key;value" localhost  
# save array
curl -d "key;value;value;value" localhost  
# show keys
curl -d "ls" localhost  
# get value
curl -d "key" localhost  
# delete key
curl -d "key;" localhost

To create simple client:

const path = './db.json' // this is default path, not required to be passed
const db = require('littledb')(path)

db.put('hello', 'world') // => "world"
db.get('hello')          // => "world"
db.ls()                  // => [ "hello" ]
db.put('hello')          // => undefined
db.get('hello')          // => undefined

Keywords