-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.js
43 lines (28 loc) · 903 Bytes
/
db.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
var db_config = {
name: 'example.db',
location: 'default'
};
document.addEventListener('deviceready', function() {
db = window.sqlitePlugin.openDatabase({
name: db_config.name,
location: db_config.location
});
function db_query(query, values=null, success_call=null, error_call=null){
db.transaction(function(tx) {
tx.executeSql(query, (values!==null) ? values : [] );
}, function(error) {
if(error_call!==null)error_call(error);
}, function() {
if(success_call!==null)success_call();
});
}
function db_select(query, values=null, success_call=null, error_call=null){
db.transaction(function(tx){
tx.executeSql(query, (values!==null) ? values : [], function(tx, rs) {
if(success_call!==null)success_call(rs);
}, function(tx, error) {
if(error_call!==null)error_call(error);
});
});
}
});