Home

Awesome

pouch-stream-server

By Build Status

PouchDB stream server. Serves generic PouchDB object streams.

Goes well with pouch-remote-stream on the client.

PouchDB version

Tested against PouchDB version 5.

Install

$ npm install pouch-server-stream --save

Use

var PouchDB = require('pouchdb');

// Create DB
var db = new PouchDB('mydb');

var PouchStreamServer = require('pouch-stream-server');


// Create a server

var server = PouchStreamServer();

// Add a database to it

server.dbs.add('mydb', db);

// Connect the streams

netServer.on('connection', function(conn) {
  var stream = server.stream();
  stream.pipe(conn).pipe(stream);
});

API

PouchStreamServer([options])

Creates a Pouch Stream server. Example:

var PouchStreamServer = require('pouch-stream-server');
var server = PouchStreamServer(options);

options is an optional object with any of the following keys:

server

server.dbs.add(dbName, db)

Adds a database that can be addressed by name from the remote stream. Example:

var db = new PouchDB('mydb');
server.dbs.add('myremotedb', db);

server.stream([options])

Returns a stream to be used to talk to a remote client.

options is an optional object with the following optional keys:

License

ISC