Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

claudia-pouchdb-replication-stream

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

claudia-pouchdb-replication-stream

This module provides a AWS Lambda endpoint for streaming bulk couchdb changes to pouchdb. It makes use of the great PouchDB Replication Stream module.

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Claudia Pouchdb Replication Stream

This module provides an express endpoint for streaming bulk couchdb changes to pouchdb. It makes use of the great PouchDB Replication Stream module.

Install

Install with npm:

npm i -S claudia-pouchdb-replication-stream

Usage

Basic usage enables streaming of one db to the client:

var ApiBuilder = require('claudia-api-builder');
var repStream = require('claudia-pouchdb-replication-stream');
const api = new ApiBuilder();
module.exports = api;


api.get('/api/couchdb', repStream('http://user:pass@localhost:5984/db'));

Database Name in Request

If you have per-user databases, or you want to get changes from different databases based on the request, this will work:

api.get('/api/couchdb/:db', repStream({
  url     : 'http://user:pass@localhost:5984/',
  dbReq   : true
}));

Filtered Replication

In order to do filtered replication, there are two options. If the parameters are known beforehand, then this method can be used:

api.get('/api/couchdb', repStream({
  url           : 'http://user:pass@localhost:5984/',
  replication   : {
    filter        : 'myFilterName',
    query_params  : {
      prop1       : 'myFilterParameter1'
    }
  }
});

However, if the filter options are also dynamic/based on the request, then the request data must be parsed first:

api.get('/api/couchdb/:filterFunc/:filterBy', function(req){
  var filterFunc = req.pathParams.filterFunc;
  var filterBy = req.pathParams.filterBy;
  repStream({
    url           : 'http://user:pass@localhost:5984/',
    replication   : {
      filter        : filterFunc,
      query_params  : {
        docName     : filterBy
      }
    }
  })(req, res, next);
});

Replication Options

Allowed replication options:

batch_size
batches_limit
filter
doc_ids
query_params
since
view

PouchDB Replication Options CouchDB Replication Options

Error Handling

The default behavior is to send an error response with a 500 error code and the error message. To overwrite this, pass a method to the error option:

repStream({
  url     : 'http://user:pass@localhost:5984/',
  error   : function(err){
    // do what you will with `err` here
    console.log(err);
    res.send(err);
  }
});

Keywords

FAQs

Package last updated on 07 Jun 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc