HTML5/Js client-side DB
We're starting development of a client application. No servers, just HTML5/JS. How to organize a local, non-relational, read-only, one-table DB?
Message | Img | Code
---------------------------开发者_开发技巧-------
File not found | error.png | 15
Access denied | error.png | 42
We want to query row(s) by a field, say, 'Code = 15'. All files should be local.
Regards,
If you need cross browser support then I would recommend localStorage.
There is a nice abstraction. store.js that allows you to store keyvalue pairs in the local storage.
Alternatively if you want proper SQL you can use Web SQL but wikipedia claims it's only supported by Opera/Safari/Chrome.
Example of store:
var Row = {
Message:"File Not Found",
Img: "error.png",
Code: 15
}
store.set(Row.Code, Row);
...
store.get("15");
It does rely on JSON which is supported by modern browsers and IE8+. To support older browsers use json2
精彩评论