AlessioF
AlessioF

Reputation: 453

Why are my data saved in WebSQL and not in IndexedDB? (ionic)

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?

Upvotes: 8

Views: 2914

Answers (2)

user12489278
user12489278

Reputation:

it is really easy just : add ‘localstorage’ to driverOrder like this::

IonicStorageModule.forRoot({
  name: “Database”,
  driverOrder: [“indexeddb”, “localstorage”]
}),

Upvotes: 1

fastr.de
fastr.de

Reputation: 1523

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

Upvotes: 1

Related Questions