Easy way to view contents of ionic-storage?


#1

I am using ionic-storage and am having some issues with debugging. I would like to be able to view the contents of storage, but using the chrome debugger it seems like nothing shows up:

Also if I set a break point in one of my components that uses storage and try to output values (or everything using forEach) like so: this.storage.get('key').then(value=>console.log(value)), it doesn’t output anything. I’m a bit lost as to how I can check to see that certain values are being set correctly without hard coding the above into my application… This is not ideal.


#2

Hello, given the fate of IonicDB (abandoned), I would strongly recommend you to ask Ionic developers if they plan to maintain Ionic storage.

Have fun with Ionic,


#3

I wouldn’t worry about that. It’s a completely different animal from IonicDB, which was a hosted service. The ionic-storage source code is fully available, and anybody could fork it. It’s largely a veneer over localforage.


#4

OK, thanks for information Rapropos.


#5

Using Developer Tools to look at the content of the Storage is absolutely right. Here is a screenshot how it should look like:

So I’d say something is broken with your implementation. Does your app actually store anything successfully?


#6

My app does sucesfully store content. When I use this.storage.forEach() to output every key, value pair I see my data. I just doesn’t appear in the debugger. Are you using the default set up or do you have some sort of configuration specified?


#7

100% default in my app


#8

By chance are you using cordova’s “browser” platform?


#9

Experiencing the same thing here. Nothing shows up in the inspector, yet all the key/values are being stored somewhere. Using all defaults for Ionic Storage. Any idea where everything is getting stored?


#10

What platform are you on?


#11

In the browser. Using Chrome.


#12

Using ionic serve or what exactly?


#13

Yes, basic ionic serve on localhost


#14

I’m on android and attempting to view the contents of storage using Chrome Debugger.

using ionic run android.


#15

Did you also install the SQLite plugin when installing Ionic Storage?


#16

Yes I have the ‘cordova-sqlite-storage’ plugin installed as well. Storage seems to be working with no issues, my only problem is that I cannot easily view the contents of storage for debugging.


#17

Yesterday i was facing same issue. But today when I run ionic serve stored data appeared. Dont know exactly what the issue is. Stop ionic serve and run it again it will appear in indexedDB in chrome.


#18

Hope this is helpful for others but not for me as I’m running an android app :frowning:


#19

Well, If someone is having this problem yet, I solved mine just inputting a parameter in config of StorageConfig, where I was using the storage, like this:

function provideStorage7() {
  return new Storage({
    name:'dbSomething',
    driverOrder: ['indexeddb', 'sqlite', 'websql'],  /* added this line */
    storeName:'table_one'
  })
}

Hope this helps! :grinning:


#20

Don’t follow the advice in the previous post. Angular DI manages Storage's lifecycle, not you.