feat: Properly store with objects in SqlStorage
Type: feat
Ionic Version: 2.x
Platform: all
Right now if you store objects through SqlStorage, they get stored as a string "[object Object]". I think it would be super helpful and developer-friendly to allow arbitrary json storage. Basically serializing and deserializing it for users. I'm sure there's a lot of considerations to make that practical so maybe you guys already discarded that use case. If that's the case, then you should document that somewhere or even log a warning when a call to .set is passing an object as the value.
var options = {};
let storage = new Storage(SqlStorage, options);
storage.set('myobj', {name:'myname'});
storage.get('myobj').then((myobj) => {
console.log(myobj);// this logs "[object Object]"
});
when logging objects in the console try doing
console.dir(myobj)
https://developer.chrome.com/devtools/docs/console-api#consoledirobject
Yes, I'm aware, same thing happens (I actually even did debugger to confirm the situation). I think WebSQL simply calls .toString() on objects, which would lead to this. Haven't tested on SQLite.
+1
I have the exact same issue with Local Storage
Hello all! We are currently refactoring the storage module to not use webSQL any more as it is a deprecated technology and is not supported any more in iOS 10 and is soon to be removed from chrome too. IndexedDB is the future of complex web storage and is what we are moving too. Because of all this I am going to be closing this issue for now. Thanks for using Ionic!