Skip to content

Repository files navigation

pouch-stream-server

ByBuild 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

varPouchDB=require('pouchdb');// Create DBvardb=newPouchDB('mydb');varPouchStreamServer=require('pouch-stream-server');// Create a servervarserver=PouchStreamServer();// Add a database to itserver.dbs.add('mydb',db);// Connect the streamsnetServer.on('connection',function(conn){varstream=server.stream();stream.pipe(conn).pipe(stream);});

API

PouchStreamServer([options])

Creates a Pouch Stream server. Example:

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

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

  • highWaterMark: The maximum number of objects to store in the internal buffer before ceasing to read from the underlying resource (when reading) or inducing back-pressure (when writing). Defaults to 16.

server

server.dbs.add(dbName, db)

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

vardb=newPouchDB('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:

  • highWaterMark: The maximum number of objects to store in the internal buffer before ceasing to read from the underlying resource (when reading) or inducing back-pressure (when writing). Defaults to 16.
  • databases: Indication of which databases are allowed to use this stream. Defaults to any. Can be either:
    • a string containing the name of the one allowed database
    • an array of strings containing the names of the allowed databases
    • a filter function that accepts the database name and returns a truthy value if the database is allowed to be used in this stream.

License

ISC

About

PouchDB Remote Server Stream

Resources

Stars

16 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages