Gearquery is a lightweight library that wraps Google Gears for easy querying and manipulation. Some project goals:
- Be lightweight
- Make CRUD dead simple
- Make DB code more DRY
To meet these goals, gearquery provides a module that takes care of:
- creating/dropping tables
- the four CRUD operations
- transactions
- before/after hooks for each CRUD operation
Here are some examples:
// create a project table and project Manager
var project = new gearquery.Manager("project", {
id: "integer not null primary key",
name: "varchar(40) not null"
});
// select all projects whose name is gearquery
project.read({name: gearquery});
project.read({}, {where: ["name = ?", "gearquery"]});
// create some projects within a transaction
gearquery.transaction(function(){
project.create({name: "Pye Automation"});
project.create({name: "Gearquery Code"});
});
// update and delete a project
project.update({name: "Gearquery V2"}, {where: ["id = ?", 2]});
project.del({id: 2});
// add hooks into gearquery's CRUD system
project.before("create", function(data){
data.name = data.name || "Default Name";
});
project.after("create", function(data){
projectCount++;
});To get started, read GettingStarted.
If you run into any bugs or want to give some feedback please email me at hugh (at) hughbien (dot) com.