my app has a list with entries that each contain a few strings and ints, i have to be able to update them
how should i store that? my only knowledge so far is server side sql so that i have no idea what else is possible
im already googling a lot about phonegap/cordova and persistent data storage but maybe theres something more useful or more elegant with angular/ionic?
if im not mistaken i have to read the whole array every time (thats saved in localstorage), find the entry i want to update a part of, change that and overwrite the whole array in localstorage with the new one, same if i add a new object, is that correct?
wouldnt that be a bad choice for id say up to 300 entries (for the beginning)?
Hi
I am also trying to solve same problem , i have couple of questions.
Does your app has authentication ,if yes how are u storing user information ?
What happens to data in localstorage when new version of app is installed ?
i dont use authentication atm and at least for development the old entry can be accessed by newer versions
but i dont know what its linked to (its not global i hope?) so you should test that for production if you rename your app or do something else
its also very annoying because i had to write something to take care of overseen new assignments without reading the old key first so that i dont delete everything in there
maybe theres some libraries out there for that? ill test lawnchair next so that might fix a few things here and there
Would agree with @jgx that the Cordova SQLite Plugin is a great option.
I have been using localForage in all of my recent projects. They also have an Angular service/directive available. Havenāt had any need for syncing with these recent projects.
I am trying to solve the same problem. I like that Angular remains flexible on data persistence solutions, it makes sense since it is a web framework not specifically a Hybrid app framework⦠would love to know how people are solving this.
Hereās an overview:
Requirements
Add local database to app build for preloaded data. This will be over the 5MB data limit.
Load data from local database on startup.
Saving updated data to local data store for persistence.
Prefer schema-less if possible.
Simple query interface. I could load all the data into memory and just use standard Angular filters for this, provided the performance was decent.
Object query interface⦠something like an ActiveRecord-like ORM rather than having to write SQL in my app.
Future proof. I donāt want to reinvent the wheel every time I am building an app that needs data persistence. Iād like to choose a solution that allows me for basic query interface, large data storage up front.
Options
Iāve been looking at the following options. Can you provide any feedback on any of these?
Breezejs - Looks more focused on server. Is there an SQLite interface?
YDN-DB - Seems like an option.
JayData - Is this still active? Concerned about commercial aspect of it.
Persistencejs - This looks promising. Is the project still active?
ngStorage - is this just a localStorage interface? Does it solve the 5M limit?
Angular-cache - Can I have data to pre-load with this? How long can I persist data?
localForage - donāt know much about this. Does it solve the 5M limit?
Pouchdb - concerned about query language. does not solve 5M restriction
Couchdb Lite - concerned about query language.
WebSQL - I donāt to use this since it seems like it is on the way out⦠plus 5M limit.
Indexeddb - There is a shim that builds compat-layer for most major browsers. 5M limit. If I could use this on top of Sqlite that would prob be a winner for me since more standards based.
Store in json file - Just use plain old objects and then use Phonegap file api to load and store serialized data. Seems like a pain to have to serialize all the data every time we want to save⦠but an option so long as I can use Angular filters.
Sorry for the long post. I really would like to see some thoughts on best practices. Would love an Angular/Ionic Way to handle large data persistence.
I use WEB SQL Database to store data in my app. If you have C#/ Entity Framework background you should familiarize yourself with HTML5 SQLite for PhoneGap/Cordova. This library is very similar to EF. It offers: Code First Mode, Data Migrations, Repositories, Linq-like query etc.
@kevbaker Have you tested GQL? Does it meet your 7 requirements?
Also what about Cordova SQLite Plugin?
I also have the same problem. Now I am using localStorage for simplicity.
However, it is not only limited on size, but also not persistent if the users just re-install the app instead of upgrading.
Hello,
i have a litte trick for my News to save it like for offline view.
I use the Cordova File plugin ( https://build.phonegap.com/plugins/617 ).
I save all my news in json format into a file on the device.
And if a close and open the device or reinstall the app, the file is always there because u can save the file persistent.
I must only read the file and json parse it again.
What about the performance, if there are hundreds of pieces of news?
Sometimes only a few pieces (say 10) should be read into the view.
But I guess it is difficult with the FileReader API to locate and load any 10 pieces into the view.
Another issue is privacy, if the data is not just news.
Of course, we can encrypt the file.
But it is better if the user does not have to memorize and input some password.
Iāve settled with localForage as it has a very good abstraction layer through localStorage-like setters and getters and it does solve the 5MB limit when other storage methods are available (it tries IndexedDB and WebSQL first, so it solves the 5MB limit almost everywhere these days).
Itās very simple to use and itās āownā choice of drivers seems consistent as Iāve tried in different environments and it always chooses the same driver for each different environment and apparently always the most logical choice.
Iām just leaving my opinion in case anyone is still undecided.
There are some good suggestions here. I use persistencejs. It has a nice ORM with support for relational data.
I have used it several times in the past (with a modified version of the āsyncā portion) to sync data between multiple devices and a web application. It is also really lightweight for the featureset.
If anyone is interested in helping refactor it into angularjs modules, let me know. I am planning to open-source a new version of the sync module with better support for $http and promises.
Thanks ⦠All suggestions in this posts are helpful and by it seems that sqlite is the best option. I only have one doubt regarding SQL. 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. )