Helps you generating websql simple queries without writing any sql code.
bower install angular-websql
- Include the
angular-websql.js
script, and this script's dependencies are included in your app. - Add
paulocaldeira17.angular.websql
as a module dependency to your app.
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"
}
})
Websql.insert('user', {"username": 'pc', "password": '1234', 'age': 22})
INSERT INTO user (username, password, age) VALUES('pc', '1234', 22)
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
Websql.del("user", {"id": 1})
DELETE user WHERE id=1
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("user")
SELECT * FROM user
Your can use common operators like =
, >=
, <=
and LIKE
. You can use also NULL
and NOT NULL
as condition values.