rollbackdb
A simple key/value database with fast rollback support.
npm install rollbackdb
Usage
var rollbackdb =// OBS: currently you have use the latest leveldown (>=1.2.0)var db = 'db' db:var rdb =rdb
API
rdb = rollbackdb(levelup, [options])
Create a new rollbackdb instance. You can set version
in options
if you want to rollback the database to a previous version
checkoutRdb = rdb.checkout(version)
Shorthand for setting the version
option in the constructor.
Returns a new instance.
rdb.get(key, [options], cb)
Get a key. Set version
in the options map to get the key that
was added in a previous version of this database.
rdb.put(key, value, [cb])
Insert a key.
rdb.del(key, [cb])
Delete a key.
rdb.batch(batch, [cb])
Insert and/or deletes a batch of key/values
rdb
rdb.changes
A property containing the total number of changes/versions added to this database
rs = rdb.createChangesStream([options])
Returns a readable stream of all changes added to this database.
You can limit the range of changes returned by using the following options
gt: changeNumbergte: changeNumberlt: changeNumberlte: changeNumber
If you only want a single change stream returned set options.change = changeNumber
rs = rdb.createReadStream([options])
Create a readable stream of all keys and values in the database. Options include
gt: 'keys-must-be-greater-than-me'gte: 'keys-must-be-greater-or-equal-to-me'lt: 'keys-must-be-less-than-me'lte: 'keys-must-be-less-or-equal-to-me'version: aVersionNumber // read all values in the database at this version
ws = rdb.createWriteStream()
Returns a writable stream that you can write {type: 'put'|'del', key: key, value: value}
pairs to.
All values written will be added to the same version.
License
MIT