7 ms·
Am I wrong to think that pouchdb uses indexeddb? Over the last 8 months, I've been working on a react/capacitor based android app (potentially ios later on) an
by throwaway743 5y ago
Am I wrong to think that pouchdb uses indexeddb?
Over the last 8 months, I've been working on a react/capacitor based android app (potentially ios later on) and was originally using idb-keyval, which uses indexeddb for key val storage, and things were great since it's a local storage solution compatible with react/capacitor, and one of my goals is to not rely on a remote data storage solution.
As said, things were going great, but then a couple weeks ago things went to shit when all the data that was stored in the prototype on my android device was wiped. Apparently, both android and ios tend to wipe browser/web-view local storage at random/when space is needed(?).
Dug around since looking for an alternative solution (would love a capacitor compatible mongodb solution), came across pouchdb via rxdb, but could've sworn there was mention that it relies on indexeddb. So just to be safe switched to sqlite and been rewriting components since.
Lesson of the story, even if it isn't dependent on indexeddb, if you're looking for a local storage option for a mobile app and happen to be using a js framework with capacitor or anything that utilizes a web-view, stay away from anything that uses indexeddb. If a wipe like this were to happen post release, the chance that your app succeeds afterwards would be near 0%
Edit: so yeah, just double checked/was reading through the readme of this project, and pouchdb via rxdb is reliant on indexeddb
- typingmonkey 5y agoAuthor here. I am using RxDB with Capacitor (iOS and Android app). You can use the SQLite based pouchdb adapter with capacitor. It keeps your data and is (sometimes) faster. Here [1] I have documented a whole section about how to use RxDB+SQLite in Capacitor. [1] https://rxdb.info/adapters.html https://rxdb.info/adapters.html
- throwaway743 5y agoAh okay cool. Thank you for pointing this out. Now would I use the adapter for react native or for cordova? If react native, I've been writing with react js and have been under the impression that react native specific plugins aren't compatible with react js. Is that wrong? If cordova, it's totally compatible with capacitor? Sorry just want to make sure before jumping in
- deesep 5y agocordova-sqlite adapter can be used with cordova and capacitor. The article says so.
- throwaway743 5y agoJust sought further confirmation as I've had issues in the past with supposed cross compatible cordova/capacitor plugins. Also wasn't sure whether it was being suggested to use the react (native) plugin or the cordova plugin, as I didn't clarify (I should have) in the parent that I'm using react js and not native.
- perttir 5y agoHow fast is the Pouchdb with sqlite on android? I dont really need any replication in my application, should i just use the normal cordova sqlite instead and switch to dexie.js when using in web browser?
- WA 5y agoCan confirm: don’t use IndexedDb in a mobile app made with Capacitor or Cordova. I never had the IndexedDB wiped by the OS, but there are occasional browser bugs that affect IndexedDb. One time, users could not load their data if their android device had less than 1 GB of free disk space, because Chrome had a bug in calculation the quota for IndexedDb. SQLite is fast and it gives me peace at night, knowing that user data is safe.
- mikojan 5y ago> Apparently, both android and ios tend to wipe browser/web-view local storage at random/when space is needed(?). "Apparently"? Mozilla docs say so much in the introduction[0], even directing you to a dedicated page[1]. [0]: https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API#storage_limits_and_eviction_criteria https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_A... [1]: https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API/Browser_storage_limits_and_eviction_criteria https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_A...
- WorldMaker 5y ago> one of my goals is to not rely on a remote data storage solution Yeah, that's going to be hard goal to meet in this case. A benefit to PouchDB over raw IndexedDB is the great replication support and replicating everything back down in the case of one of those worst case wipes is an alright solution in some cases (but that does require managing remote data storage solutions, unfortunately). Android and iOS are supposed to manage IndexedDB as Application Storage when installed as an app via something like Capacitor, but it's still not great. Supposedly Android is getting a lot better about it for apps installed as PWAs instead and Capacitor should give you a good PWA path for Android at least. (iOS is unfortunately still lagging far behind on PWA support.)