node-cadb

0.1.2 • Public • Published

node-cadb

Content Addressable DataBase. Similair to git in how it stores your data to the disk. A memory aware way of easily having many versions of the same set of objects on the disk. Written entirely asynchronously to be used by node.js.Much of the terminology comes from git. Depends on jssha and fs.extra. If you want to run unit tests they depend on nodeunit. If using an older version you should really upgrade it now installs and passes the unit tests bundled with it.

usage example

var nodeCADB = require('node-cadb');
//create a repo
var repo = new nodeCADB.Repo(__dirname + '/test');
//initialize this repository with an empty master index and the internal folder structure
repo.init(function(){
    //save second argument array of data to the first argument the branch
    repo.saveBranch('master', ['hello from ', 'node-cadb'],
            function() {
	      //callback is executed once complete
		//loads a branch and fires the calllback for each item in the data array
		//with the indices of the whole branch and the data in each item
                repo.loadBranch('master', function(indices, data) {
		    //you could also reconstruct the data on the client side by
		    //hashing it again and finding it's proper place in the indices array
		    //it is not guaranteed to come in order
                    console.log(indices);
                    console.log(data);
                });
            });
});

there is also repo.clone

//source dest callback
repo.clone('master', 'newbranch', function(){

});

Readme

Keywords

Package Sidebar

Install

npm i node-cadb

Weekly Downloads

0

Version

0.1.2

License

MIT

Last publish

Collaborators

  • mp4