ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

RC0 migration question

Open okonon opened this issue 10 years ago • 14 comments

@jgw96 did you guys get rid of SqlStorage ?. In beta 11 i used to do:

import { SqlStorage, Storage } from 'ionic-angular';
...
storage = new Storage(SqlStorage);

But after rc0 upgrade am getting following error: /node_modules/ionic-angular/index"' has no exported member 'SqlStorage'.

okonon avatar Sep 28 '16 21:09 okonon

Please check the changelog: https://github.com/driftyco/ionic/blob/master/CHANGELOG.md#200-rc0-2016-09-28

It is mentioned under Storage: https://github.com/driftyco/ionic/blob/master/CHANGELOG.md#storage

Thanks!

brandyscarney avatar Sep 28 '16 21:09 brandyscarney

@brandyscarney can you pleas point me where it says anything about SqlStorage or copy text here ? Thanks a lot

okonon avatar Sep 28 '16 22:09 okonon

@brandyscarney i search changelog page for sqlstorage and did not find any info.

okonon avatar Sep 28 '16 22:09 okonon

Ah, valid question! I'll reopen this to look into documentation, but here is the source for Storage: https://github.com/driftyco/ionic-storage/blob/master/src/storage.ts#L14-L27

brandyscarney avatar Sep 28 '16 22:09 brandyscarney

this is now 404: http://ionicframework.com/docs/v2/api/platform/storage/Storage/

okonon avatar Sep 28 '16 22:09 okonon

Yeah I talked to the team and we are going to work on getting the docs generated for Storage. I created an issue on our site repo to make sure this gets added: https://github.com/driftyco/ionic-site/issues/800

Going to close this and work to get it added will be there!

brandyscarney avatar Sep 28 '16 23:09 brandyscarney

Hi. it's good but how to make queries? So now we have only key/value implementation

pivalig avatar Sep 29 '16 07:09 pivalig

Same question. How we can perform query on local DB?

For example In beta11 I wrote:

import {Storage, SqlStorage} from 'ionic-angular'; ... this.storage = new Storage(SqlStorage); this.storage('CREATE TABLE mytable (field1 TEXT,field2 TEXT,field3 TEXT)'); this.storage('SELECT * FROM mytable'); ... this.storage('INSERT INTO mytable ('field1','field2','field3') VALUES ('v1','v2','v3')'); ...

riccardotreagles avatar Sep 29 '16 13:09 riccardotreagles

+1

tunele avatar Sep 29 '16 14:09 tunele

+1

andrezap avatar Sep 30 '16 15:09 andrezap

+1

meeximum avatar Sep 30 '16 20:09 meeximum

this.store = new Storage(SqlStorage, {name: "Db"});

this.store.query("CREATE TABLE IF NOT EXISTS lista (id INT PRIMARY KEY NOT NULL, record TEXT)")

This works for me, but only on serve --lab, on emulator or device Database seems to fail...

pimol avatar Oct 03 '16 21:10 pimol

Hey all, we don't support this in the new storage engine, and here's my response on why that's the case: https://github.com/driftyco/ionic/issues/8269#issuecomment-250590367

tl;dr: if you want to use a SQL database, just use SQLite directly, from ionic-native or another plugin. WebSQL is deprecated so usage of that is shaky. Additionally, using SQLite directly gives you full access to the engine and all the features, without going through a layer like SqlStorage that may or may not expose all those features. Sorry for not communicating that but we think this is the best way to move forward and there are some options in that issue on how to get the old service back (considering the code is still available in a github history somewhere!)

mlynch avatar Oct 04 '16 00:10 mlynch

@mlynch The problem about the use of SQLite directly is that you can't test it on a browser (if I'm right), so you have to run app in device / emulator.

rafaelss95 avatar Oct 04 '16 17:10 rafaelss95