What is the best way to store data locally in a cross platform way? I assume that in a PhoneGap app on Android I won't have a DBService running, so I can't use my old Enyo 1.0 code anymore. Which is too bad because I really like the non-SQL/JSON object interface.
I've seen references to localStorage (WebKit specific?) and the wrapper that omastudios wrote that enyo-izes it. I understand it has a size limit of 5MB. But how does this compare to DBService?
For larger data stores, PhoneGap's Storage interface provides access to a SQLite Db. Is there an enyo-ized interface available for this -- something that would convert from JSON objects to SQL? Or is that in works for Enyo 2.0?
0 • •
Comments
- Spam
- Abuse
0 • Off Topic Insightful •https://gist.github.com/2317017
Since it's not actually a patch, but a different version, I wasn't sure how to bring it to his attention using GitHub. Ben, can you figure out what to do with this? Thanks!
Scott
- Spam
- Abuse
0 • Off Topic Insightful •- Spam
- Abuse
0 • Off Topic Insightful •Incidentally, @cookie, SQLite is not really a great alternative for localStorage if you are worried about hitting the 5 MB limit, because the same limit is typically applied to SQLite databases, as well. It's mainly a good alternative if you don't want to keep all your data in memory, need to do selects that only target certain columns, sort things database-side instead of in Javascript, etc.
However, relying on PhoneGap's Storage/WebSQL is not a fantastic option, either, because recent iOS updates will arbitrarily trash your local data from time to time if memory gets tight and there's nothing you can do to prevent it. For TapWatch I ended up writing a simple custom PhoneGap plugin that acts like localStorage, but writes the strings you pass it straight to the application sandbox as text files (and falls back on localStorage for other platforms). If you're working with small data sets, it works great. I'll try to remember to clean up the code and open source it soon.
- Spam
- Abuse
0 • Off Topic Insightful •- Spam
- Abuse
0 • Off Topic Insightful •- Spam
- Abuse
0 • Off Topic Insightful •- Spam
- Abuse
0 • Off Topic Insightful •lastInsertId()method:1. It will only be set after an insert query succeeds, so you have to access it in your onSuccess method for the insert. A common mistake with the Database class is to try and do things synchronously, which won't work
2. The insert ID will only be set if you have done a single insert. If you are doing a bulk insert using the
queries()method, it theoretically should not save anything to lastInsertId.It's certainly possible that setting the insertID might be failing. The call that sets it is wrapped in a try/catch block, so if you want to debug it try adding some console logging or similar to the catch and see what errors it's reporting. I haven't tested the class on Android at all, so it's quite possible that there's a wrinkle to how it handles the WebSQL API or similar that the code doesn't take into account yet.
- Spam
- Abuse
0 • Off Topic Insightful •http://onecrayon.github.com/database-webos/
- Spam
- Abuse
0 • Off Topic Insightful •- Spam
- Abuse
0 • Off Topic Insightful •- Spam
- Abuse
0 • Off Topic Insightful •- Spam
- Abuse
0 • Off Topic Insightful •- Spam
- Abuse
0 • Off Topic Insightful •