level-range
Find all K/V-pairs prefixed by a certain key.
An often used range query when working with leveldb.
Usage
Given this data stored in a leveldb at /tmp/db
:
and a script test.js
that takes argv
and outputs found data:
var levelup = ;var db = ;var JSONStream = ;var range = ; ;
The output will be:
$ node test.js a-bucket[{"key":"0","value":"some"},{"key":"1","value":"test"},{"key":"2","value":"data"}] $ node test.js another-bucket[{"key":"0","value":"nope"}]
API
range(db, prefix, args...)
Create a range stream. args
will be fed into util.formt
together with prefix
so you can
use placeholders there.
Installation
With npm do:
$ npm install level-range
License
(MIT)