apache / apache/pouchdb

PouchDB to CouchDB sync is not happening when I use filter design document

Open
#8,996 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
17.6k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

PouchDB to CouchDB sync is not happening when I use filter design document. Sync can pull the CouchDB data into PouchDB. When I update a record on the PouchDB. It's not syncing with CouchDB

### My Sync code
this.pouchDB
.sync(this.couchDB, {
live: true,
heartbeat: true,
timeout: false,
retry: true,
back_off_function: backOffFunction,
filter: 'filters/by_unit',
query_params: { units: JSON.stringify(selectedUnits) }
})

### CouchDB filter design document
{
"_id": "_design/filters",
"_rev": "1-906cb674d5e8db7ae497285df540b183",
"filters": {
"by_unit": "function(doc, req) { if (doc._id.startsWith(\"_design/\")) { return true; } var units = JSON.parse(req.query.units || '[]'); return units.indexOf(doc.unitId) !== -1; }"
}
}

### NOTE
For the same filter replicate works fine but not for sync

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.