hi, I am having trouble creating foreign key constraints on the database created with it. I have tried executing query 'PRGAMA foreign_keys = ON'
but it is not working. Can anyone suggest me a way to use foreign key constraints with the SQLite plugin.
To share my experiencesā¦
Iāve had similar requirements to yourself (initial DB is 75Mb ish created from an existing sql database). I now have a working solution with an SQLite database. The solution and instructions on how to get it up and running are in this post Prepopulated SQLite Databases in Ionic - #6 by n40jpj
I have used SQL for all of my queries and the following plugin to get the database over to the device in the first instance : GitHub - an-rahulpandey/cordova-plugin-dbcopy: Copy SQLite Database from www folder to default app database location . I havenāt used an ORM, but thatās just because I havenāt looked to find one. I use EF and Hibernate heavily, but I like keeping my plugins to a minimum.
Regarding :
If I use the SQL database the same way I use localstorage , every time a relevant view is loaded the data is pulled from database will it increase the overhead as database calls will be made every time that view is loaded. ( Presently the data is pulled from localstorage. )
That really depends on your coding style and implementation, you can cache the page and or write a service to store some data in memory so that it only gets retrieved from the database when you specifically request it.
There are loads of tools out there for managing SQLite databases free and paid.
The above are my opinions only and suit my requirements, I am however more than happy to discuss better methods.
has any one looked into angular-data ?
How does locaForage solve the 5Mb limit? Arenāt all of IndexedDB, WebSQL and localStorage all limited to 5Mb?
If space wasnāt an issue Iād use localStorage but as it is Iām trying to use SQLite which is much higher maintenance. Iāve already created some nice localStorage methods but realised that space would be an issue
Wrong, you can now plug it to Sqlite with the Sqlite Cordova Plugin, then : No restriction.
Actually I have, since the time I wrote the post, switched to PouchDB, even without using the sync capabilities it manages the offline part really well and as @ronycohen said you can plug it the SQLite plugin so no 5Mb restriction there.
With that being said I remember that the angular module I talked about in my post: localForage, also had capabilities to plug in another data drivers if Iām not mistaken, but then again I may be wrong.
You should give PouchDB a try. Even without a CouchDB on our server it is an hassle-free SQLite interface for our ionic app.
Is the storage size unlimited?
FYI, SQLite stores data in a file, so ultimately all data comes from a file
Just want to add some information about local storage and crosswalk
https://lists.crosswalk-project.org/pipermail/crosswalk-help/2014-October/000535.html
Iām using local storage and was worried about size limit, apparently they testet it and were able to save 5200000 characters but not 5300000. For the moment I guess it will be fine, although the performance might be the bigger problem in the end.
Anyone can confirm this?
I have started to use Pouchdb after seeing some people recommend it and it seems to work really well so far! Local storage was my first choice but I was running out of room and Pouchdb solves that using the SQLite plugin
Can you link to a tutorial that shows us how?
go to http://pouchdb.com/guides/
Also managing the conflicts errors is pretty hard.
you need to understand the ārevisionā way of thinking.
Iāve ended up now just using the ngCordova wrapper of pure SQLite now, but using it in a similar way to local storage or Pouchdb where Iāve just got one table where the contents is just key pair values (e.g. column one = āuser?user1ā, column two = json data)
Eliminates all the unnecessary bloat of the pouchdb library!
I was looking for a way to store a few strings on the device that would persist even if the app is removed and installed again. It is possible to achieve this on both iOS and Android but in a different method.
On iOS, using the keychain (https://github.com/shazron/KeychainPlugin) and on Android, using the file plugin and writing to the cordova.file.externalRootDirectory directory.
I wrote an angular service (ng-persist) that has the same API for both platforms and uses the methods above. I also blogged about it in more detail here.
We are using Couchbase Lite
To be honnest I looked at a lot and I finally made my choice on Pouchdb
Easy to use and integrate. Json file storing. Lot of tutos on the web.
How About using Firebase as Local Datastore in IONIC - 3 by Angular Fireā¦