You can't replicate to more than 6 database with PouchDB because many browsers has 6 maximum paralel connection. PouchDB uses long poll HTTP connection to watch changes, thus hitting the maximum paralel connection.
This helper provides a custom fetch method to watch changes via WebSocket so it won't hit maximum connection limitation. It uses standard fetch if the operation is not a long poll operation.
Just read the source code. It's short.
socket-pouch?
Why not useBecause it doesn't work in my case. I can't create index and other things also doesn't work. I don't know why. Just try it by yourself. Is it working? If yes then use it. If not then maybe this helper is a good news for you.
socket-pouch is also a whole new adapter while my helper is not an adapter. It's just a fetcher so it more likely to work since I don't introduce any custom adapter.
How to
Example code is available in folder example
.
Server
Yes, you need to run a server. This is the proxy to provide the WebSocket interface.
const createServer = ; const wsServer = ; wsServer; // wsServer.close();
You can also use HTTPS to run WSS.
const https = ;const createServer = ; const httpsServer = https; httpsServer; const wsServer = ;
Client
;const fetchWs = ; // this is all of it // do what you usually doconst dbRemote = name: `http://localhost:5984/nameDbRemote` fetch: fetchWs;const dbLocal = name: 'nameDbLocal';const replicator = dbLocalreplicate;replicator;
API
createServer(options)
Create a new server instance. Read this and this. Returns server object.
createFetchWs(urlWs)
Create a fetcher to be used by PouchDB. urlWs
is the URL to the server.