PouchDB stream server. Serves generic PouchDB object streams.
Goes well with pouch-remote-stream on the client.
Tested against PouchDB version 5.
$ npm install pouch-server-stream --save
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);});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.
Adds a database that can be addressed by name from the remote stream. Example:
vardb=newPouchDB('mydb');server.dbs.add('myremotedb',db);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.
ISC