Giter Club home page Giter Club logo

izzywebsql's Introduction

IzzyWebSQL

A little and easy library to develop applications that need connection with web sql.

  1. Open or create
  2. Create database schema
  3. Connection
  4. Get All
  5. Get
  6. Insert
  7. Update
  8. Remove

##Open or create

To create or open a database simply just set your version, the name and display name.

// DB properties  		
	var version = 1.0,
	    name = 'example',
	    displayName = 'exampleDB';
	    
  var db = new DB(name, version, displayName);

##Create DB Schema

It's very easy. Just set the tables and fields for each one and add in database.

// DB Schema
var taskTable = new Table('tasks',[
  ['id', 'INTEGER PRIMARY KEY AUTOINCREMENT'],
  ['name', 'TEXT'],
  ['owner', 'VARCHAR(255)']
]);

// Add table
db.addTable(taskTable);

##Connection

To make the DB execute the SQL statements you need to start a connection.

// Use DB					
db.connect();	

##Get All

Returns all elements of the table.

db.getAll('tasks', function(sqlResult){

  var tasks = sqlResult.rows;
  
  for(var i = 0; i < tasks.length; i++){
		console.log(tasks.item(i).name);
	}
  
});

##Get

Returns a table element by ID.

db.get('tasks', 1, function(sqlResult){
  
  var task = sqlResult.rows.item(0);
  console.log(task);
  
});

##Insert

Inserts an element in the table.

db.insert('tasks', [
  ['name', 'Someone task'],
  ['owner', 'Developer']
]);

##Update

Updates a table element by ID.

db.update('tasks', 1, [
  ['name', 'Other task'],
  ['owner', 'Developer of Steel']
]);

##Remove

Removes a table element by ID.

db.remove('tasks', 1);

izzywebsql's People

Contributors

brunoquaresma avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

rgazeredo

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.