ionic-team / ionic-storage

Ionic Storage module for Ionic apps
MIT License
437 stars 99 forks source link

Cannot find Driver enum. #319

Open fudom opened 5 months ago

fudom commented 5 months ago

Please update docs. https://github.com/ionic-team/ionic-storage?tab=readme-ov-file#adding-driver-to-configuration

Where do you get Drivers? In @ionic/storage-angular (v4.0.0) types it's just type any. There is not export for Drivers enum.

Workaround: Use string names like 'indexeddb' and 'localstorage'. Update: Names does not work on browser (without Cordova sqlite).

IonicStorageModule.forRoot({
  driverOrder: [CordovaSqLiteDriver._driver, 'indexeddb', 'localstorage'],
})

It only works if I completly remove driveOrder. I wonder what is value of Drivers.IndexedDB?

This does not work:

IonicStorageModule.forRoot({
  driverOrder: ['indexeddb', 'localstorage'],
})

Doc comment: Possible default driverOrder options are: ['indexeddb', 'localstorage'] and the default is that exact ordering. Lie? Because IonicStorageModule.forRoot() works.

wrzr123 commented 3 months ago

As just found in this thread: https://github.com/ionic-team/ionic-storage/issues/318

Add the following import: import { Drivers } from '@ionic/storage'; Then it will work.

Documentation should be updated accordingly.

fudom commented 1 month ago

This is not available in @ionic/storage-angular. It has no exported member 'Driver'. As workaround we could do this: import { INDEXEDDB, LOCALSTORAGE } from 'localforage'; It seems that this project is dead.

Why is Drivers not available as you show in readme.md documentation? It does not appear in import. Why @hidden?

https://github.com/ionic-team/ionic-storage/blob/26040a96c999acccd8072161c0ee10afb14da57c/lib/src/index.ts#L3-L8

v4.0.0

@mlynch cc