Consume a remote PouchDB stream.
Goes well with
pouch-stream-server on the server side.
Tested against PouchDB version 5.
$ npm install pouch-remote-stream --save
var Remote = ;
var remote = ;
var remoteDB = 'mydb'adapter: 'remote'remote: remote;
var stream = ;stream;
, for example to sync a local DB:
var localDB = 'someLocalDB';localDB;
You can pipe it to and from any duplex object stream.
If you need to work with a raw duplex stream (like a TCP or a web socket), you will need to encode and decode the stream. For example, you can use a new-line separated JSON duplex stream like this:
var JSONDuplexStream = ;var JSONStream = ;var rawDuplexStream = ;// raw => JSON.in => remote.stream => JSON.out => rawrawDuplexStream;
Here's an example of using a TCP stream and reconnecting if the connection goes down:
var Remote = ;PouchDB;var Reconnect = ;var reconnect =;var options =port: 80host: '127.0.0.1';var re =;