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 =bytewise =level = ;// create the database and make it immutablevar db =;// these commands will be execute with a slight delayvar cmds = put update del ;{dbimmutable;}{dbimmutable;}{dbimmutable;}// times will store the timestamps when the operations were each completedvar times = i = 0;{if cmdslength === 0 return ;var cmd = cmds;;};// get the value of 'eugene' at the time just before it was deleted// effectively this uses a snapshot of the database at that time{dbimmutable;}{if err return ;// the data was fetched even though it was 'deleted'// a db.get('eugene'), would throw a 'NotFoundError'to;}