17 |
all(sql, callback1, callback2) { |
all(sql, callback1, callback2) { |
18 |
return this.db.all(sql, callback1, callback2); |
return this.db.all(sql, callback1, callback2); |
19 |
} |
} |
20 |
|
|
21 |
|
runAsync(sql, paramsOrCallback = []) { |
22 |
|
return new Promise((resolve, reject) => { |
23 |
|
this.db.run(sql, paramsOrCallback, err => { |
24 |
|
if (err) { |
25 |
|
reject(err); |
26 |
|
return; |
27 |
|
} |
28 |
|
|
29 |
|
resolve(); |
30 |
|
}); |
31 |
|
}); |
32 |
|
} |
33 |
|
|
34 |
|
getAsync(sql, paramsOrCallback = []) { |
35 |
|
return new Promise((resolve, reject) => { |
36 |
|
this.db.get(sql, paramsOrCallback, (err, data) => { |
37 |
|
if (err) { |
38 |
|
reject(err); |
39 |
|
return; |
40 |
|
} |
41 |
|
|
42 |
|
resolve(data); |
43 |
|
}); |
44 |
|
}); |
45 |
|
} |
46 |
|
|
47 |
|
allAsync(sql, paramsOrCallback = []) { |
48 |
|
return new Promise((resolve, reject) => { |
49 |
|
this.db.all(sql, paramsOrCallback, (err, data) => { |
50 |
|
if (err) { |
51 |
|
reject(err); |
52 |
|
return; |
53 |
|
} |
54 |
|
|
55 |
|
resolve(data); |
56 |
|
}); |
57 |
|
}); |
58 |
|
} |
59 |
} |
} |
60 |
|
|
61 |
module.exports = Database; |
module.exports = Database; |