Announcing Ionic Storage v3

Originally published at: Announcing Ionic Storage v3 - Ionic Blog

Photo by Lucas van Oort on Unsplash Today I’m thrilled to announce the release of Ionic Storage v3, an open-source library that offers an easy way to store simple data in Ionic apps. Ionic Storage is useful for building single code-base apps on iOS, Android, and the Web, while automatically using the best storage engine…

2 Likes

Hi

Thx for this and last week migrated fairly flawlessly.

The key design decision (angular) was the exact location to do the create knowing that multiple locations use storage

I opted for OnInit in app.component.ts.

Doing instead in a provider at root level would require me to mirror get and set, which seems to me a bit too much

Rgdz

Tom

1 Like

How did you initialize the storage in app.component.ts?

What I have done:

async ngOnInit() {
    await this.storage.create();
  }

but I am facing the following error:
ERROR Error: Uncaught (in promise): Error: Database not created. Must call create() first
assertDb

Also did you define the drivers? If so how?
I did the following:

await this.storage.defineDriver(localStorage);

I am facing the following error:
ERROR Error: Uncaught (in promise): Error: Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver

Please help understand what I may have done wrong and how to fix the issues

Hi

in app.compontent.ts in constructor:

this.storage.create()

And in app.module.ts

    IonicStorageModule.forRoot({
      name: 'myname',
      driverOrder: [Drivers.IndexedDB] // , Drivers.LocalStorage
    }),

Can’t say where you go wrong. For starters, defineDriver needs to go before create.

I did so on both files.

I managed to solve it after uninstalling and reinstalling it. I dont know why but it is working now

1 Like