1

I have a problem in replication with filter. Everything works ok, but when i would like to change the category name which pass the filter in source db, the same record in target database still exists, but it doesn't pass the filter now, so the record in the target database should be deleted. How can i solve this problem? There is my replication function. :

nano.db.replicate('db1', 'db2',
     { create_target:true, continuous: true, filter: 'DESIGNDOCUMENT/CATEGORY'  }).then((body) => {
       console.log(body);
});

And below is my replication filter:

{
      "_id": "_design/DESIGNDOCUMENT",
      "_rev": "2-4c0bde4916dcaf68c58d904792f191f0",
      "filters": {
        "CATEGORY": "function(doc, req) { if (doc.category === 'category1' ) { return true; } return false; }"
      }
}
Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
MarMar1236
  • 41
  • 1
  • 6
  • This is a tricky problems. There are multiple solutions detailed here: https://stackoverflow.com/questions/23983739/couchdb-filtered-replication-remove-a-document One easy solution is to delete the database and recreate another when when changing filter. – Alexis Côté Mar 14 '19 at 19:17

0 Answers0