Best data persistence for Angularjs/Javascript Apps on PhoneGap
Angular remains flexible on data persistence solutions, it makes sense since it is a web framework not specifically a Hybrid app framework...
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 app.
Options
Options are following :
- Breezejs - Looks more focused on server. Breeze is a JavaScript library that helps you manage data in rich client applications. If you store data in a database, query and save those data as complex object graphs, and share these graphs across multiple screens of your JavaScript client, Breeze is for you.
- YDN-DB
- JayData - Concerned about commercial aspect of it.
- Persistencejs - This looks promising.
- ngStorage - Is this just a localStorage interface.
- Angular-cache
- localForage - localForage is a fast and simple storage library for JavaScript. localForage improves the offline experience of your web app by using asynchronous storage (IndexedDB or WebSQL) with a simple,
localStorage
-like API. - Pouchdb - concerned about query language. does not solve 5M restriction. Install the PhoneGap plugin, it'll work cross-browser and you'll avoid the storage limit on iOS/Android
- Couchdb Lite - concerned about query language.
- WebSQL - The initial limit will be 50mb. WebSQL has a nice query language, but you want to be future-proof, i.e., not chain yourself to a dead standard. There's also Windows Phone and Firefox OS to consider
- Indexeddb - There is a shim that builds compat-layer for most major browsers. The initial limit will be 50mb. The syntax will be really easy to use in your angular project. 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 we can use Angular filters.
Comments
Post a Comment