level-immutable
LevelDB/Levelup immutable history and database snapshotting based on ideas in
datomic.

Installation
This module is installed via npm:
$ npm install level-immutable
Background
The datomic database simplifies database by making all it's data mutable, and
by storing facts and data changes with the timestamp that they happened, so
you can interrogate the database at a particular point in the past with a
consistent "snapshot" of the data at that time.
This module emulates this behaviour, allowing you to pass in fromTime
and
toTime
values into the levelup options
object in order to get the answers
at that particular time.
Example Usage
var immutable = require('level-immutable'),
bytewise = require('bytewise'),
level = require('level');
var db = immutable(level('/path/to/my/db',
{ keyEncoding: bytewise, valueEncoding: 'json' }));
var cmds = [ put, update, del ];
function put(cb) {
db.immutable.put('eugene', { name: 'Eugene', color: 'blue' }, cb);
}
function update(cb) {
db.immutable.put('eugene', { name: 'Eugene', color: 'black' }, cb);
}
function del(cb) {
db.immutable.del('eugene', cb);
}
var times = [], i = 0;
(function next() {
if (cmds.length === 0) return get();
var cmd = cmds.shift();
cmd(function (err) {
if (err) return done(err);
times[i++] = Date.now();
setTimeout(next, 5);
});
})();
function get() {
db.immutable.get('eugene', { toTime: times[1] }, check);
}
function check(err, data) {
if (err) return done(err);
expect(data).to.eql({ name: 'Eugene', color: 'black' });
}