Robert Kroeger has free a pleasant accumulation for topical database access. The Web Storage Portability Layer nicely abstracts on crowning of HTML5 and Gears for database access.
The WSPL consists of a assemblage of classes that wage anachronic transactional admittance to both Gears and HTML5 databases and crapper be institute on Project Hosting on Google Code.
There are fivesome base classes:
google.wspl.Statement - A parametrizable SQL evidence class
google.wspl.Transaction - Used to fulfil digit or more Statements with ACID properties
google.wspl.ResultSet - Arrays of JavaScript hash objects, where the hash key is the plateau article name
google.wspl.Database - A unification to the championship database, also provides dealings support
google.wspl.DatabaseFactory - Creates the pertinent HTML5 or Gears database implementation
Also included in the organisation is a ultimate note-taking covering with a continual database store shapely using the WSPL library. This covering (along with Gmail ambulatory for iPhone and Android-powered devices) is an warning of the cache pattern for antiquity offline scheme applications. In the store pattern, we append a browser-local store into the scheme covering to fortuity the coetaneous unification between individual actions in the covering and server-generated responses. Instead, as shown below, we hit digit accumulation flows. First, all topical to the device, table distinction from the store to the UI patch changes prefabricated by the individual update the cache. In the ordinal flow, the store asynchronously forrad individual changes to the scheme computer and receives updates in response.
By using this architectural pattern, a scheme covering crapper prefabricated unbigoted of a tender (or modify absent) meshwork connection!
You crapper of instruction verify a extreme at the cipher to wager how it works, for example:
-
-
google.wspl.DatabaseFactory.createDatabase = function(dbName, dbworkerUrl) {
-
var dbms;
-
if (window.openDatabase) {
-
// We hit HTML5 functionality.
-
dbms = new google.wspl.html5.Database(dbName);
-
} else {
-
// Try to ingest Google Gears.
-
var gearsDb = goog.gears.getFactory().create(‘beta.database’);
-
var wp = goog.gears.getFactory().create(‘beta.workerpool’);
-
-
// Note that Gears module not earmark enter supported URLs when creating a worker.
-
dbms = new wireless.db.gears.Database();
-
dbms.openDatabase(‘’, dbName, gearsDb);
-
wp.onmessage = google.bind(dbms.onMessage_, dbms);
-
-
// Comment this distinction discover to ingest the coetaneous database.
-
dbms.startWorker(wp, dbworkerUrl, 0);
-
}
-
return dbms;
-
};
-
Nicely done. It would be enthusiastic to wager a edition that acts as a shim and when in Gears fashion manually implements the HTML5 accepted API so you crapper indite your individual cipher to that and not a newborn google package.





