pouch-remote-stream
Consume a remote PouchDB stream.
Goes well with pouch-stream-server
on the server side.
PouchDB versions
Tested against PouchDB version 5.
Install
$ npm install pouch-remote-stream --save
Getting started
1. Require it
var Remote = ;
2. Add the PouchDB adapter
PouchDB.adapter('remote', Remote.adapter);
3. Create the remote
var remote = ;
4. Create the remote PouchDB database
var remoteDB = 'mydb' adapter: 'remote' remote: remote ;
5. Pipe it to and from a duplex stream
var stream = ; stream;
6. Use the PouchDB remote DB
, for example to sync a local DB:
var localDB = 'someLocalDB';localDB;
Any stream, really
You can pipe it to and from any duplex object stream.
Encode and decode streams
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 => raw rawDuplexStream ;
You can use with reconnect:
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: 80 host: '127.0.0.1'; var re = ;
License
ISC