Coder Social home page Coder Social logo

angular-websql's Introduction

Angular WebSql Service

Helps you generating websql simple queries without writing any sql code.

Setup

  1. bower install angular-websql
  2. Include the angular-websql.js script, and this script's dependencies are included in your app.
  3. Add paulocaldeira17.angular.websql as a module dependency to your app.

Methods

Create Table

Websql.createTable(string tableName, object fields)

Example:

Websql.createTable('user', {
  "id":{
    "type": "INTEGER",
    "null": "NOT NULL",
    "primary": true, // primary
    "auto_increment": true // auto increment
  },
  "created":{
    "type": "TIMESTAMP",
    "null": "NOT NULL",
    "default": "CURRENT_TIMESTAMP" // default value
  },
  "username":{
    "type": "TEXT",
    "null": "NOT NULL"
  },
  "password": {
    "type": "TEXT",
    "null": "NOT NULL"
  },
  "age": {
    "type": "INTEGER",
    "null": "NOT NULL"
  }
})

Drop Table

Websql.dropTable(string tableName)

Insert

Websql.insert(string tableName, object fields)

Example:

Websql.insert('user', {"username": 'pc', "password": '1234', 'age': 22})
INSERT INTO user (username, password, age) VALUES('pc', '1234', 22)

Update

Websql.update(string tableName, object fields)

Examples:

Websql.update("user", {"username": 'paulo.caldeira'}, {
  'id': 1
})
UPDATE user SET username='paulo.caldeira' WHERE id=1
Websql.update("user", {"age": 23}, {
  "username": {
    "operator":'LIKE',
    "value":'paulo.*'
    "union":'AND' // condition suffix
  },
  "age": 22
})
UPDATE user SET age=23 WHERE username LIKE 'paulo.*' AND age=22

Delete

Websql.delete(string tableName, object where)

Websql.del("user", {"id": 1})
DELETE user WHERE id=1

Select

Websql.select(string tableName, object where)

Websql.select("user", {
  "age": {
    "value":'IS NULL',
    "union":'AND'
  },
  "username":'IS NOT NULL'
})
SELECT * FROM user WHERE age IS NULL AND username IS NOT NULL

Websql.selectAll(string tableName)

Websql.selectAll("user")
SELECT * FROM user

Operators

Your can use common operators like =, >=, <= and LIKE. You can use also NULL and NOT NULL as condition values.

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.