1.0.0 • Published 7 years ago

oak-lite v1.0.0

Weekly downloads
28
License
-
Repository
github
Last release
7 years ago

oak-lite

Build Status codecov npm Dependency Status devDependency Status

Oak-Lite is a lightweight version of Oak, a write-only database with a publish-subscribe model.

Getting Started

Install the oak-lite package into your project with npm.

npm install oak-lite --save

Use the oak-lite module in your project.

import Oak from 'oak-lite';

// Configure the database (see the configuration options)
let database = Oak.configure({
    dataDirectory: '/var/lib/myapp/oak'
});

// Select the 'counter' rack
let rack = database.selectRack('counter');

// Subscribe to the rack
let subscription = rack.subscribe(barrel => {
    // Print each barrel to the console
    console.log(barrel);
});

// Publish 3 barrels to the rack
rack.publish(1);
rack.publish(2);
rack.publish(3);

// Unsubscribe from the rack after 10 seconds
setTimeout(() => {
    subscription.unsubscribe();
}, 10 * 1000);

Configuration

The following parameters can be defined when configuring an Oak-Lite database:

ParameterDescriptionRequiredDefault
dataDirectoryThe directory used by this database to store racksYesnone

API

The public interface for oak-lite is defined in the API Guide.

Contributing

Pull requests are welcome! To get started, see the Contributing Guide.