My favorites | Sign in
Logo
                
People details
Project owners:
  atsn.ngs

Documentation


DBClass.js

An O/R Mapper, supporting Adobe AIR, Gears, HTML5, Yahoo! Widgets.



Download from SVN Repository



Notepad Demos: HTML5 / GEARS



Example:

// DBClass.create returns new Class instance
var MyDB = DBClass.create("dbclass_test",10000,DBClass.Adapter.AUTO,"1.0","DBClass Demo");
// Create new instance
var db = new MyDB();
// Defining fields
var id = new AbstractSQL.Field(
  "id",  AbstractSQL.FieldType.INTEGER, null, true, null, AbstractSQL.Conflict.ABORT,
  true, true, AbstractSQL.Conflict.FAIL, true, AbstractSQL.Conflict.FAIL
);
var name = new AbstractSQL.Field(
  "name", AbstractSQL.FieldType.TEXT, 0xff
);
var fields = [id,name]
// Initialize schema
var schema = db.schema("sample", fields);
schema.init(onSchemaInitialize);

function onSchemaInitialize(success) {
  if(!success) return alert("Failed to Initialize schema!");
  // SELECT id, name FROM sample;
  schema.select(["id", "name"], null, null, null, function(success) {
    if(!success) return alert(this.error.message||"An error has occurred.");
    this.each(function(i){ // Called for each rows.
      console.log( this.id, this.name );
    });
  });
}

AbstractSQL.js

Generates SQL syntax from JavaScript object structure.



Download from SVN Repository

Demo



Example:

var sql = new AbstractSQL("test");
sql.select(["id","name"],[
	new AbstractSQL.WhereList(AbstractSQL.Logic.OR,[
		new AbstractSQL.Where("id",100),
		new AbstractSQL.Where("id","101")
	])
]);
console.log(sql);
// SELECT id,name FROM test WHERE (id=100 OR id='101');

Try here.










Hosted by Google Code