hedgehogdb
v0.2.4
Published
minamalist distributed database for hedgehogs
Downloads
17
Readme
hedgehogdb
[in progress!]
Install
npm install hedgehogdb -g
CLI
hedgehogdb
Starts hedgehogdb & milton pub/sub server listening on port 8000
hedgehogdb -l 9999
Starts hedgehogdb & milton pub/sub server listening on port 9999
Client Library
Append JSON documents to a collection
var client = require('hedgehogdb/client')();
var event = {
data: 'hello world!!!'
};
client.append('hello_world_collection', event);
Appending to a non-existant collection will create it. All documents are ordered by automatically ordered by insert time.
Get all documents from a collection
var client = require('hedgehogdb/client')();
client.get('hello_world_collection', function (row) {
console.log(row); // will fire for each row in the collection
if (row.end) { console.log('retrieved all items'); }
});
Get a list of collections
var client = require('hedgehogdb/client')();
client.collections(function (data) {
console.log(data.collections);
// [ 'hello_world_collection' ]
});
Live subscription to a collection via milton pub/sub
var milton = require('milton/client');
// host and port of the hedgehogdb server...
//
client = milton({ host: '192.168.0.100', port: 8000 });
client.on('hedgehog:some_collection', function (row) {
console.log('[some_collection] new row added ', row);
})
// as a pull stream source
var pull = require('pull-stream');
var source = require('milton/pull/source')({ host: '192.168.0.100', port: 8000 });
pull(
source('some_collection'),
pull.log()
)