Skip to content

gnowoel/pouchdb-in-service-worker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Trying to sync the local PouchDB with a remote CouchDB in a service worker. It uses background sync to trigger a single-shot replication.

Arrangement

In the web page:

  • Create local and remote databases
  • Sync databases for the first time
  • Watch for changes and trigger sync events
  • Register a service worker

In the service worker:

  • Create local and remote databases
  • Capture the sync event and sync databases

Running

$ npm install && bower install
$ npm start

Caveats

  • We have PouchDB instances in both the web page and the service worker, but the sync event will only be triggered when changes of data happen in the web page (i.e. changes from within the service worker will be ignored).
  • I tried to do the initial sync in the service worker, but failed with a 500 error (due to some _local records missing if we use db.replicate(), or empty response if we use db.sync()).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published