Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including arangochair with all npm packages installed. Try it out:

var arangochair = require("arangochair")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

arangochair v4.0.2

`arangochair` pushs ArangoDB changes in realtime to you

arangochair

arangochair pushs ArangoDB changes in realtime to you.

install

npm install --save arangochair

quick example

const arangochair = require('arangochair');

const no4 = new arangochair('http://127.0.0.1:8529/'); // ArangoDB node to monitor

const no4 = new arangochair('http://127.0.0.1:8529/myDb'); // ArangoDB node to monitor, with database name

no4.subscribe({collection:'users'});
no4.start();
no4.on('users', (doc, type) => {
    // do something awesome

    // doc:Buffer
    // type:'insert/update'|'delete'
});

no4.on('error', (err, httpStatus, headers, body) => {
    // arangochair stops on errors
    // check last http request
    no4.start();
});

subscribe

// subscribe to all events in the users collection
no4.subscribe('users');

// explicit
no4.subscribe({collection:'users', events:['insert/update', 'delete']});


// subscribe the users collection with only the delete event
no4.subscribe({collection:'users', events:['delete']});

// subscribe the users collection with only the delete event on key myKey
no4.subscribe({collection:'users', events:['delete'], keys:['myKey']});

unsubscribe

// unsubscribe the users collection
no4.unsubscribe('users');

// unsubscribe the delete event in the users collection
no4.unsubscribe({collection:'users',events:['delete']});

// unsubscribe the key myKey in the users collection
no4.unsubscribe({collection:'users',keys:['myKey']});
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free