I can't understand this simply thing. I need to store data in a database so, following the ionic documentation, I did exactly what this page says:
https://ionicframework.com/docs/storage/
I read on web that WebSQL is deprecated so I'd like to use IndexedDB to store data. The problem is that using get/set methods and running "ionic serve" I see that data is stored in WebSQL (in the form of a string, so difficult to see objects like in IndexedDB).
What am I doing wrong? How to store in IndexedDB and why prefer it to WebSQL?
IndexedDB used to have a competing spec called WebSQL Database, but it was deprecated by the W3C. While both IndexedDB and WebSQL are solutions for storage, they do not offer the same functionalities. WebSQL Database is a relational database access system, whereas IndexedDB is an indexed table system.
Today we will explore the differences between Ionic Storage, Capacitor Storage, plain SQLite storage, and Ionic's Secure Storage solution.
From the Docs
Configuring Storage
The Storage engine can be configured both with specific storage engine priorities, or custom configuration options to pass to localForage. See the localForage config docs for possible options: https://github.com/localForage/localForage#configuration
You have to pass the order correctly.
IonicStorageModule.forRoot({
name: '__mydb',
driverOrder: ['indexeddb', 'sqlite', 'websql']
})
if so delete sqlite
and websql
and try again
it is really easy just : add ‘localstorage’ to driverOrder like this::
IonicStorageModule.forRoot({
name: “Database”,
driverOrder: [“indexeddb”, “localstorage”]
}),
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