mahi-man
mahi-man

Reputation: 4676

Could not sync Pouch DB to remote DB (Cloudant) with a filter

I cannot sync my local Pouch DB with a remote DB when using a filter - I keep getting a "Uncaught (in promise)" error in the console. My sync command is:

localDB.sync(remoteDB, {
    live: true,
    filter: 'taskfilter/alltasks'
});

Upvotes: 0

Views: 251

Answers (1)

mahi-man
mahi-man

Reputation: 4676

My issue was that the filter function did not yet live in my local Pouch DB (only available in the remote DB). Solution is to break out the sync command into two replicate commands and only put the filter on one-way like so:

PouchDB.replicate(localDB, remoteDB, {live: true});
PouchDB.replicate(remoteDB, localDB,{
    live: true,
    filter: 'taskfilter/alltasks'
});

Hopefully this will save someone else some pain... or remind me to not make the same mistake again!

Upvotes: 2

Related Questions