Of course replace with your type or let as you want.
Compilation is now ok, running with ionic serve is ok too and I confirm that in debug I see my informations into IndexedDB
P.S.: And for those who use localstorage
From release notes:
Storage has been removed from ionic-angular and placed into a separate module, @ionic/storage. Starters have been updated to add this, make sure to add it to your package.json if you’re using the storage system. See more details here.
[03:04:28] Error: Module c:\Projects\POC1\node_modules\localforage\dist\localforage.js does not export default (imported by c:\Projects\POC1\node_modules\@ionic\storage\es2015\storage.js)
at Module.trace (C:\Projects\POC1\node_modules\rollup\dist\rollup.js:7677:29)
at ModuleScope.findDeclaration (C:\Projects\POC1\node_modules\rollup\dist\rollup.js:7300:22)
at Scope.findDeclaration (C:\Projects\POC1\node_modules\rollup\dist\rollup.js:5351:39)
at Scope.findDeclaration (C:\Projects\POC1\node_modules\rollup\dist\rollup.js:5351:39)
at Identifier.bind (C:\Projects\POC1\node_modules\rollup\dist\rollup.js:6489:29)
at C:\Projects\POC1\node_modules\rollup\dist\rollup.js:5151:50
at AssignmentExpression.eachChild (C:\Projects\POC1\node_modules\rollup\dist\rollup.js:5168:5)
at AssignmentExpression.bind (C:\Projects\POC1\node_modules\rollup\dist\rollup.js:5151:7)
at AssignmentExpression.bind (C:\Projects\POC1\node_modules\rollup\dist\rollup.js:5511:23)
at C:\Projects\POC1\node_modules\rollup\dist\rollup.js:5151:50
Hey @alejandrocao, I finished my migration and localforage seems to work fine for me. If I reckon I did
-Installlocal forage:
sudo npm install localforage --save
-Install definition
sudo npm install @types/localforage --save
-As I already mentioned (see above), no more * in import and it’s important to not forget to specify the types (like getItem and setItem) when you use the library
Let me knows if these steps worked for you too, hope so
I think node_modules/@types/localforage was already installed by ionic. Although it works it feels kinda hacky so I’m still interested in the proper solution for this.
As @gasaki already mentioned you should use @ionic/storage.
This uses LocalForage when running in a desktop browser only if no “better” option is available or e.g. SQLite when running on a device.
Here is the description:
/**
Storage is an easy way to store key/value pairs and other complicated
data in a way that uses a variety of storage engines underneath. Currently,
Storage uses localforage underneath to abstract away the various storage
engines while still providing a simple API.
When running natively, Storage will prioritize using SQLite, as it’s one of
the most stable and widely used file-based databases, and avoids some of the
pitfalls of things like localstorage that the OS can decide to clear out in
low disk-space situations.
When running in the web or as a Progressive Web App, Storage will attempt to use
IndexedDB, WebSQL, and localstorage, in that order.
*/
I’d like to note that you can avoid the neccessity of editing the rollup.config.js in the node_modules by
creating a rollup.config.js and mention it in package.json like the Ionic conference app does.
Thanks for the info @reedrichards. I followed your steps and it works great in the browser. Unfortunately on my Android, some analytics is failing with Invalid action (it almost looks unrelated, but this is the error I get every time I try to access the db)
11-07 20:45:15.638 10419 10419 D SystemWebChromeClient: file:///android_asset/www/plugins/cordova-sqlite-storage/www/SQLitePlugin.js: Line 175 : OPEN database: _ionicstorage
11-07 20:45:15.639 10419 10419 I chromium: [INFO:CONSOLE(175)] “OPEN database: _ionicstorage”, source: file:///android_asset/www/plugins/cordova-sqlite-storage/www/SQLitePlugin.js (175)
11-07 20:45:15.643 10419 10666 V SQLitePlugin: Android db implementation: built-in android.database.sqlite package
11-07 20:45:15.645 10419 14481 V info : Open sqlite db: /data/user/0/com.directoryontap/databases/_ionicstorage
11-07 20:45:15.649 10419 10419 D SystemWebChromeClient: file:///android_asset/www/plugins/cordova-sqlite-storage/www/SQLitePlugin.js: Line 106 : new transaction is waiting for open operation
11-07 20:45:15.649 10419 10419 I chromium: [INFO:CONSOLE(106)] “new transaction is waiting for open operation”, source: file:///android_asset/www/plugins/cordova-sqlite-storage/www/SQLitePlugin.js (106)
11-07 20:45:15.788 10419 10419 D SystemWebChromeClient: file:///android_asset/www/plugins/cordova-sqlite-storage/www/SQLitePlugin.js: Line 179 : OPEN database: _ionicstorage - OK
11-07 20:45:15.788 10419 10419 I chromium: [INFO:CONSOLE(179)] “OPEN database: _ionicstorage - OK”, source: file:///android_asset/www/plugins/cordova-sqlite-storage/www/SQLitePlugin.js (179)
11-07 20:45:15.789 10419 10419 D SystemWebChromeClient: file:///android_asset/www/plugins/cordova-sqlite-storage/www/SQLitePlugin.js: Line 80 : DB opened: _ionicstorage
11-07 20:45:15.789 10419 10419 I chromium: [INFO:CONSOLE(80)] “DB opened: _ionicstorage”, source: file:///android_asset/www/plugins/cordova-sqlite-storage/www/SQLitePlugin.js (80)
11-07 20:45:15.866 10419 10666 W CordovaPlugin: Attempted to send a second callback for ID: UniversalAnalytics929104835
11-07 20:45:15.866 10419 10666 W CordovaPlugin: Result was: “Invalid action”
Hi I’m still having an issue where its asking me to include Storage in the providers for each page? I don’t understand where I’ve gone wrong. Can anyone help?