filterreplicationpouchdbdesign-documents

Filter design documents with PouchDB


I'm using a design document to ensure that only owners can modify docs. How can I prevent couchdb from replicating this design document?


Solution

  • You can use the filter option in changes() and replicate(), e.g.

    var opts = {
      live: true,
      filter: function(doc) {
        return doc._id.indexOf('_design') !== 0;
      } 
    };
    var db = new PouchDB('todos');
    db.replicate.to('http://localhost:5984/todos', opts);