1. Robert Steckroth
  2. Indurate Database

Source

Indurate Database /

Filename Size Date modified Message
Gecko_Browser_Phonegap_examples
Qt_QML_examples
13 B
Closing in on completeness
68 B
Supports Ubuntu Touch, Gecko, Phonegap and Nodejs in one file
34.3 KB
Fix to script
2.1 KB
Added better desing for listners
5.8 KB
Version 1.3 is well on its' way
23.3 KB
Added Table Object describing
1015 B
Added better desing for listners
3.7 KB
Added Table Object describing

Indurate Database

A wrapper for WebSql and openDatabase

NPM

Author: Robert Edward Steckroth II

Digital Persona: Surgemcgee, Bustout RobertSteckroth@gmail.com

Licence: GNU GENERAL PUBLIC LICENSE Version 3

Description:

Indurate.js is a user friendly API for server and mobile applications. Indurate uses WebSql openDatabase with a strong object oriented structure. Indurate can provide database driven applications or supplement existing mobile applications.

Features:

  • Works with Ubuntu Touch, Phonegap, Nodejs and Gecko based browsers
  • SUper simple table management
  • Pretty database and table printing
  • Asynchronous or synchronous code structure
  • Impossible to break or use corrupted data

Example usage

var db = new IndurateDatabase({name: "MyApplication", version: 1.0, description: "A cool database for everyone (except some people)", size: 4*1024*1024})
// create or use if does not exist a new table here (My Cool Table). This is the only command which uses db (IndurateDatabase) prototype other than "describe"
    // In here we have a Table object from now on. ALl other command chains will use this.$() as table management

// Returns the table command here
var table = db.$("My Indurate Tabledd", ["MyColumn", "Second column"], function() {
    console.log("Here we go..")

    this.$("getTable", function() { 
        console.dir(this) // this will be empty the first tiome this script is be run
                          // after that the "getTable" command will populate this with the entire table data
        this['first'] = {"MyColumn": "First has been changed is set", "Second column": "Initial Data"}
        this['second'] = {"MyColumn": "column data in here", "Second column": "Some data for this"}
        this.$("describe", function() {
            this.$("set", function() {
                this.$("describe", function() {
                    this['first'] = {"MyColumn": "Random number "+(Math.round(Math.random() * 99999999)), "Second column": "more data for this column"}
                    this['third'] = {"MyColumn": "A another column! What?"} // will be set to a empty string if column data is not set
                    this.$("set", function () {
                        this.$("getTable", function() { 
                            // Last event to fire. Call our other stuff now
                            console.dir(this)
                            more_stuff()
                        })
                    })
                })
            })
        }).$("set").$("describe") // This will be called before the internal stuff so it will show the initial table data
    }).$("describe", function(out) { console.log("This is called after the first getTable command callback is fired\n"+out)} ) // Append pretty printing to log message

}, function(tx, err) { 
    console.log('I am in db global still!\n'+err.message)
    this.$("describe") // <- !THIS IS THE ONLY TIME WE HAVE ACCESS TO DATABASE COMMAND
    // This will not happen in the sucess callback either.
}) // Close out the database scope.  


// The database needs to be at rest before we can call it in a gloabal setting.
// Rember that the asynchronous format will run everything all at once.
function more_stuff() { // CAREFULL
    console.dir(table) // These two are the same thing
    table.$("describe", function() {
        console.dir(this) // These two are the same thing
    })
    // We should implement a listner to call this stuff when the databases calls are finished
    // For now, database describing remains broken
    db.$("describe")
    db.$("describe", function(out) { // specifying a success callback  here will disable defualt logging and provide the pretty table text into an argument (out)
        console.log("\n---- I WILL CONTROL PRETTY PRINTING ---- \n\n"+out)
    })
}

example output table describe

___________________________________________________________________________________________
|key        |name                      |last_updated                           |has_failed|
|___________|__________________________|_______________________________________|__________|
|my_key . . |Surgemcgee . . . . . . . .|Sat Oct 26 2013 10:58:54 GMT-0400 (EDT)|false . . |
|another_key|Robert Edward Steckroth II|Sat Oct 26 2013 10:52:52 GMT-0400 (EDT)|No way! . |
|___________|__________________________|_______________________________________|__________|

example output show database

| Show Database: example     Version: 1.0     Size(bytes): 3145728   Description: Example database for indurate.js
| Rows: 5    Columns: 5
______________________________________________________________________________________________________________________________________________________________________________________________________________________
|type |name                       |tbl_name                   |rootpage|sql                                                                                                                                          |
|_____|___________________________|___________________________|________|_____________________________________________________________________________________________________________________________________________|
|table|__WebKitDatabaseInfoTable__|__WebKitDatabaseInfoTable__|3 . . . |CREATE TABLE __WebKitDatabaseInfoTable__ (key TEXT NOT NULL ON CONFLICT FAIL UNIQUE ON CONFLICT REPLACE,value TEXT NOT NULL ON CONFLICT FAIL)|
|table|userTable . . . . . . . . .|userTable . . . . . . . . .|5 . . . |CREATE TABLE userTable(name TEXT UNIQUE, value TEXT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
|table|peopleTable . . . . . . . .|peopleTable . . . . . . . .|7 . . . |CREATE TABLE peopleTable(name TEXT UNIQUE, value TEXT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
|_____|___________________________|___________________________|________|_____________________________________________________________________________________________________________________________________________|