A HTML5 Client Side Database ORM for jQuery based on Hibernate
JQuery 1.6+
orJQuery 2.0.0+
(Recommend the latest stable version)
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="https://raw.github.com/perrygeorget/jquery-db/master/dist/jquery.db.0.1.3.min.js"></script>
Download the distribution and get started!
All database operations happen asynchronously.
var db = $.db("people", "1.0", "People Database", 1024 * 1024);
- Database name
- Version number
- Text description
- Size of database
db.createTable({
name: "person",
columns: [
"serial_number INTEGER PRIMARY KEY",
"name TEXT",
"rank TEXT",
],
done: function () {
console.log("Yay! My first table.");
},
fail: function () {
console.log("Something went wrong....");
}
});
Outputs:
Yay! My first table.
db.tables(function(tables) {
console.log(tables);
});
Outputs:
["person"]
db.insert("person", {
data: {
serial_number: 7779311,
name: "Pepper",
rank: "Sergeant"
},
done: function () {
console.log("Yay! I created a person!");
},
fail: function () {
console.log("Something went wrong....");
}
});
Outputs:
Yay! I created a person!
db.criteria("person").list(
function (transaction, results) {
var rows = results.rows;
for (var i = 0; i < rows.length; i++) {
var row = rows.item(i);
console.log(row.rank + " " + row.name + " [" + row.serial_number + "]");
}
},
function (transaction, error) {
console.log("Something went wrong....");
}
);
Outputs:
Sergeant Pepper [7779311]
Detailed documentation is available on the wiki.
All code contributions are welcome.
No releases as of yet. This project is still in early development.