Hello all,
I’m trying to sync PouchDB to Couchbase via Sync Gateway. It’s all working fine when I sync all docs (within my allowed channels). However, when I try to add a filter, to do filtered replication, PouchDB is giving a 400 error (Bad request).
My filter currently just returns true, so is about as simple as you can get and should just let all docs through. I am adding the filter design doc to PouchDB with the following function:
function addFilterIndex_sync() {
var designDoc = {
"_id": “_design/sync_filter”,
“filters”: { “sync_filter”: function(doc, req) { return true; }.toString() }
};
database.put(designDoc).then(function (result) {
}).catch(function (err) { /* handle errror */ });
}
This appears to be successful (at least, there is no error from the put command). I am trying to use it in the sync in the following way:
database.sync(remoteDatabase, {
live: true,
retry: true,
filter: ‘sync_filter’,
query_params: { ‘project’: project }
})….
If I comment out the “filter:” line it all works fine and I get all my docs. With the filter specification I get the 400 error.
This is with PouchDB 5.4.5 and Sync Gateway 1.2.1.
I have already asked this question to the PouchDB community, and received the following reply from Nolan Lawson:
“we don’t run the full test suite against CSG and I know not every API works. You might try syncing PouchDB -> CouchDB -> CSG instead”
I don’t want to use CouchDB as we are already using Couchbase and it’s suited our needs so far. I find it difficult to believe that CSG doesn’t support filtered replication and that others aren’t using this, so I think I’m probably just doing something silly. Can anyone please help?
Thanks,
Giles
Thanks
I have already asked this question in the PouchDB community, and received the following response from Nolan Lawson