A database that tracks changing revisions of data.
Each revision is accessible through a unique ref which is based on a cryptographic hash of the data's content and history. A ref is similar to a git commit hash.
Each written data object is combined with a link to its ancestors - the combination is called a revision. A revision can be compared to a git commit object.
Revisions look like this:
ancestors: 'someref'data: 'some data'
The cryptographic hash of the revision is its ref.
revisions.createDB(opts) -> db
db.put(data, [ancestorRefs], cb)
db.head(cb) -> ref
db.setHead(ref, [previousHead], cb)
db.setRemoteHead(remoteName, ref, cb)
db.refDifference(fromRef, toRef, cb)
db.commonAncestor(ref1, ref2, cb)
db.createStream(refs) -> stream
revisions.createSynchronizer(sourceDB, targetDB) -> synchronizer
name: 'your-db-name' // will generate uuid if omittedrevisionStore: revStorebranchStore: branchStore
revStore being an object with a content-addressable store interface:
put(data, cb): should write some data and responds with a unique identifier of the data in the callback
get(identifier, cb): should respond with the data in the callback
del(identifier, cb): should delete the data for the specified identifier
branchStore is expected to be a simple key-value store interface:
put(key, value, cb)
The difference is computed using the graph-difference module.###db.commonAncestor(ref1, ref2, cb) Responds with the common ancestor ref of two refs.
The common ancestor is computed using the ancestor module.###db.ancestors(ref, cb) Responds with the ancestors of `ref`. ###db.createStream(refs) -> stream Returns a [simple-stream](https://github.com/mirkokiefer/simple-stream) source for reading the revisions for a given list of refs. ###db.writeStream(stream, cb) Writes the `stream` source of revisions to the database. ###revisions.createSynchronizer(sourceDB, targetDB) -> synchronizer `sourceDB` is expected to be an object with the subset of db functions and properties:
refDifference(fromRef, toRef, cb)
targetDB requires the following set of functions:
setRemoteHead(remoteName, ref, cb)
This project was created by Mirko Kiefer (@mirkokiefer).