1

The pouchdb documentation says that the pouchdb-adapter-localstorage plugin is experimental. But, it also says that it passes all the CI tests. So, I am not sure whether this is a problem with my system or a problem with the plugin, but the problem only occurs when I add { adapter: localstorage } to the object new PouchDB('mydb', opts) initialization. PouchDB seems to neither be able to retrieve pre-existing documents from Sync Gateway nor able to save new documents it creates to Sync Gateway but pre-existing documents do exist and Sync Gateway is configured properly to receive changes from the client.

Here's my code:

var auth_url = 'http://user:password@localhost:4984/mydb'
var local_options = {
    adapter: 'localstorage'
}
var remote_options = {
    ajax: {
        cache: false,
        timeout: 12000,
        crossDomain: true
    },
    adapter: 'localstorage',
    skip_setup: true
}
var sync_options = {
    live: true, 
    retry: false
}

var local_db = new PouchDB('mydb', local_options)
var remote_db = new PouchDB(auth_url, remote_options)
var db_sync = PouchDB.sync('mydb', auth_url, sync_options)

To repeat, sync works as expected when I omit adapter: 'localstorage', and no error is being thrown in the console so I know the adapter is being added. It also seems to have no problem storing and retrieving changes that it makes locally, but it is neither pulling nor pushing docs from/to the remote. So, I'm inclined to believe that either I have my configurations for localstorage not setup properly or that the plugin does not support synchronization.

Any ideas?

EDIT: It is possible that localstorage fails because this functionality may not be available on Chrome.

R J
  • 4,473
  • 2
  • 22
  • 29

0 Answers0