Database 0.9.5

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.



Details

Author
André Fiedler
Current version
0.9.5
GitHub
SunboX/mootools-database
Downloads
3511
Category
Utilities
Tags
Report
GitHub Issues

Releases


Dependencies

  • _self_/_current_: core:1.2.4: '*'

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 = resultSet.next()){
            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');
}

Demo

You can see a simple demo in this shell.


Options

  • 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.

Limitations

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 SQLite.org 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

Todo

  • begin/end transaction

License

See license file.


Projects Using Mootools Database


Discuss

A note on comments here: These comments are moderated. No comments will show up until they are approved. Comments that are not productive (i.e. inflammatory, rude, etc) will not be approved.

Found a bug in this plugin? Please report it this repository's Github Issues.

blog comments powered by Disqus