Generator style node interface to LevelDB.
Works best with co.
var le = require('le');
var co = require('co');
var db = le('db');
co(function*(){
yield db.set('foo', 'bar');
console.log('foo: %s', yield db.get('foo'));
})();
$ npm install le
Expect things to change as le grows with its usage. So it's only being used in tiny webapps.
Create or open the db at path
.
Get the value at key
.
Set the value at key
to value
.
Delete the value at key
.
Create a batch.
Queue setting key
to value
.
Queue deleting the value at key
.
Write the batch of operations.
Get all keys (inside range
).
Get all values (whose keys are inside range
).
db#keys()
and db#values()
accept string ranges of those formats:
""
/"*"
: get all
"prefix*"
: all keys must start with prefix
"[from,to]"
, "[from,to)"
, "(from,to]"
, "(from,to)"
: all keys must be
inside the interval, see
interval notations.
For infinity
to x and vice versa omit the boundary, like [,to]
.
In most cases that's less verbose than:
{
"gte": "from",
"lte": "to"
}
or
{
"gte": "prefix!",
"lte": "prefix!~"
}
which can be expressed simply as [from,to]
and prefix!*
.
For now, everything is stored as JSON
.
Set the env var DEBUG=le
to see what and when it's doing internal operations.
MIT