Giter Site home page Giter Site logo

jquery-db's Introduction

jquery-db

A HTML5 Client Side Database ORM for jQuery based on Hibernate

Requirements

  1. JQuery 1.6+ or JQuery 2.0.0+ (Recommend the latest stable version)

Usage

<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!

Getting Started

All database operations happen asynchronously.

Creating an Instance of a Database

var db = $.db("people", "1.0", "People Database", 1024 * 1024);
  1. Database name
  2. Version number
  3. Text description
  4. Size of database

Create Your First Table

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.

List the Tables in Your Database

db.tables(function(tables) {
	console.log(tables);
});

Outputs:

["person"]

Adding a Record to Your Database

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!

Selecting the Records of Your Database

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]

Documentation

Detailed documentation is available on the wiki.

Contributing

All code contributions are welcome.

Release Notes

No releases as of yet. This project is still in early development.

jquery-db's People

Contributors

perrygeorget avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

jquery-db's Issues

update

how can we update records?

Changing Versions Fails

Migrating to a more recent version of a Web SQL Database schema fails.

current version of the database and oldVersion argument do not match

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.