https://github.com/kessler/websql-sugar
something to make web sql sweeter
https://github.com/kessler/websql-sugar
Last synced: 22 days ago
JSON representation
something to make web sql sweeter
- Host: GitHub
- URL: https://github.com/kessler/websql-sugar
- Owner: kessler
- License: mit
- Created: 2014-11-06T17:24:30.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-10-12T22:19:10.000Z (over 8 years ago)
- Last Synced: 2025-04-04T03:31:54.376Z (28 days ago)
- Language: JavaScript
- Homepage:
- Size: 11.7 KB
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# websql-sugar
Use this to build data access layers on top of websql, e.g:
```javascript
var db = require('websql-sugar')({ name: 'mydb', version: '1.1' })module.exports = {
listScans: function (cb) {
// readonly api
// select queries can be issued from newTx() too
// the singleSelectCallback will require the user of the result to write less boilerplate code
// and just handle the actual data
db.newRtx().query('SELECT * FROM scan').execute(db.singleSelectCallback(cb))
},insertFoo: function (x, y, cb) {
db.newTx()
.query('INSERT INTO foo (x, y) VALUES (?, ?)',[x, y])
.execute(db.singleInsertCallback(cb))
},updateScan: function (endTime, infected, id, cb) {
db.newTx()
// can just pass the arguments if they appear in the same order of the query parameters
.query('UPDATE scan SET end=?, infected=? WHERE id=?', arguments)
.execute(db.singleSelectCallback(cb))
}
}
```### What's wrong with websql api?
1. who designs properties that throws exceptions? printing objects is like walking in a mine field and that is exactly what happens in a websql query result!
2. the callbacks are not in node.js convention :(