Sorry is this is a silly question, then I am drowning in a glass of water (not rare BTW). Is there any way to setup a web (ideally cordova) application with a preloaded (ready to use) PouchDB database(s)? Ideally what I'd want is having a PouchDB database(s) file(s) ready to use when doing db = new PouchDB('databaseName') without having to load all documents at the very first time the app is run.
I know there is the pouchdb-replication-stream but I'd need the dump file to load and then the size of the application data would be duplicated (both in the dump file and then the PouchDB database(s)). Also no chance for remote loading.
Cheers!!
Edit: you can now preload a SQLite database or use pouchdb-load; there are instructions in this blog post.
Currently the only way to completely preload is to use the SQLite Plugin, then have a build step where you use PhantomJS and copy the SQLite files into your app.
I don't generally recommend the SQLite Plugin due to 1) general instability of implementation and 2) slowness compared to IndexedDB/WebSQL. So if I were writing such an app and I wanted the best possible preload performance, I would:
pouchdb-dump-cli to dump to a filepouchdb-load into a PouchDB, throw up a spinner on initial load while the app is loading if you really need to.Some optimizations you could do here:
worker-pouch plugin works on Android (not iOS sadly), and can be used to avoid blocking DOM operations. Should work with the pouchdb-load plugin, or you can just do everything inside of a worker (better to avoid any blocking, not just IndexedDB-related blocking).If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With