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.

1 Like

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

After upgrading from v2 to v3 storage-angular, I lost all previously saved storage. I have no special configuration for drivers(although I am using the sql-lite storage for saving transactional data). Could you please let me know if this is expected behaviour or I am doing something wrong?

Thanks
Md Najmul Hoda

1 Like

Hello,

Do you know what is the max size when using indexedDb ?

i’m using @ionic/storage-angular and when checking under Application in Chrome DevTools, i’m under the QuotaExceededError. So, i’m happy :wink:

Nevertheless, something strange happened. The indexedDb never decrease, even if the size of properties decrease.

The only way is to “clear site data”.

Thanks,

capacitor 3.0 storage plugin give error on device
ERROR Error: Uncaught (in promise): Error: “Storage” plugin is not implemented on android
i follow this official doc.

Did you manage to keep your data after the update? I encounter the same issue

Yes, I was able to fix the issue. Pleas follow this thread.

As usual the documentation is confusing. The first thing it tells you to do is remove Ionic Storage v2 - npm uninstall @ionic/storage and install v3 - npm install @ionic/storage-angular. Which I did.

Then it says below, “Finally, instead of using explicit strings for driverOrder , a new Drivers enum should be used:”, but to do this you need @ionic/storage installed. If you uninstalled @ionic/storage how do you set the Drivers enum? It clearly shows in the example you need to import Drivers from ‘@ionic/storage’.

Can someone confirm you will need to have both installed to set the Drivers enum?

I just started with Ionic and read your post. I see that when you have @ionic/storage-angular installed then you can import from @ionic/storage also. So no need to have both packages insalled. Hope It will help.