Find file
Fetching contributors…
Cannot retrieve contributors at this time
85 lines (57 sloc) 2.21 KB

Mootools Database Wrapper

Offers a Mootools way to interface with html5 databases (also known as "persistent storage"). Tries to use google gears if no html 5 database is found. It requires Mootools and is tested with v1.2.4.



You can see a simple demo in this shell.

How to Use

var db = new Database('Mootools_Database_Demo');
db.execute('SELECT name FROM demo WHERE id = ?;', {
    values: [123],
    onComplete: function(resultSet){
        while(row ={
            alert(row.get('name')); // You can get columns by key
            alert(row.get(0));      // or by index
    onError: function(error){
        alert('Oops: ' + error.message);

 * To make it easier for you to update your app without
 * breaking compatibility with earlier versions of your
 * databases, the Database wrapper supports versioning.

if(db.getVersion() == '1.0') {
    db.execute('ALTER TABLE demo RENAME TO production');
    db.changeVersion('1.0', '2.0');


  • version - (string: defaults to "1.0") New databases will be created with the given version number.
  • estimatedSize - (int: defaults to 65536) A estimated size, in bytes, of the data to be stored in the database.
  • installGoogleGears - (boolean: defaults to true) If set to true it promps to install google gears.


HTML 5 Databases

  • Only the most recent versions of browsers support html 5 storage: FireFox 3.6, Fennec 1.0, Safari 4, Mobile Safari

Google Gears Databases

  • Gears uses SQLite, which has limitations. See the SQLite limitations article on for more information
  • The end user must approve a site to use Gears
  • SQLite supports about 2 GB worth of data
  • Under the hood, large strings must be fragmented as there is a limit to the number of characters that can be written per SQL statement


  • begin/end transaction


See license file.

Projects using Mootools Database