1.1.1 • Published 11 years ago

kv v1.1.1

Weekly downloads
85
License
-
Repository
github
Last release
11 years ago

kv-stream

super simple key-value store, intended for keeping appendable files.

works on the server, with files, and in the browser with localStorage.

on the server, it keeps the files in prefixed subdirectories, so that the directories do not get too large.

(see ls .git/objects/* for a similar example)

examples

###create an instance

setup is optional. setup is passed the stream created by put and get, may replace the stream passed to put/get by default, the stream is handled as newline seperated json.

//server
var kv = require('kv')('/tmp/kv')
//client
var kv = require('kv')('kv:') //this will be prefixed to keys when saving in localStorage.

put a stream

opts is optional. see fs.createWriteStream

stream.pipe(kv.put(key, opts))

get a stream

opts is optional. see fs.createReadStream

kv.get(key, opts).pipe(stream) 

del a stream

kv.del(key, callback)

list of keys

kv.list() //yes, it's sync

has

check if db has a key

  kv.has(key, function (err, stat) {
    //return the stat of the stream, if it exists.
  })

customization

to handle other types of streams than newline separated json, pass in a stream setup function to kv.

var rawKV = require('kv')(dir, function (stream, key) {
  return stream //just use raw streams, do not parse!
})

cli

there is also a cli tool!

npm install kv -g

echo hello | kv put hello --base /tmp/kv
kv get hello --base /tmp/k
1.1.1

11 years ago

1.1.0

11 years ago

1.0.8

11 years ago

1.0.7

11 years ago

1.0.6

11 years ago

1.0.5

12 years ago

1.0.4

12 years ago

1.0.3

12 years ago

1.0.2

12 years ago

1.0.1

12 years ago

1.0.0

12 years ago

0.5.8

12 years ago

0.5.7

12 years ago

0.5.6

12 years ago

0.5.5

12 years ago

0.5.4

12 years ago

0.5.3

12 years ago

0.5.2

12 years ago

0.5.1

12 years ago

0.5.0

12 years ago

0.4.1

12 years ago

0.4.0

12 years ago

0.3.2

12 years ago

0.3.1

12 years ago

0.2.1

12 years ago

0.2.0

12 years ago

0.1.0

12 years ago