Compare commits
2 Commits
35de949788
...
fe4936c7f8
Author | SHA1 | Date | |
---|---|---|---|
fe4936c7f8 | |||
2e1e28cfc9 |
@ -153,17 +153,41 @@ class QueryWrapper {
|
|||||||
execute(db) {
|
execute(db) {
|
||||||
if (this.isAnyOf("INSERT", "UPDATE", "DELETE")) {
|
if (this.isAnyOf("INSERT", "UPDATE", "DELETE")) {
|
||||||
return this.executeRun(db);
|
return this.executeRun(db);
|
||||||
|
} else if (this.isAnyOf("PRAGMA")) {
|
||||||
|
return this.executeGet(db);
|
||||||
} else {
|
} else {
|
||||||
return this.executeAll(db);
|
return this.executeAll(db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
executeGet(db) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const self = this;
|
||||||
|
|
||||||
|
(0,_log_mjs__WEBPACK_IMPORTED_MODULE_2__.log)(this.sql);
|
||||||
|
db.get(this.sql, ...this.args, function (err, row) {
|
||||||
|
if (err) {
|
||||||
|
reject(_node_adapter_error_mjs__WEBPACK_IMPORTED_MODULE_0__.NodeAdapterError.from(err));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = {};
|
||||||
|
|
||||||
|
if (row) {
|
||||||
|
result.rows = [row];
|
||||||
|
}
|
||||||
|
|
||||||
|
resolve(_response_wrapper_mjs__WEBPACK_IMPORTED_MODULE_1__.ResponseWrapper.success(result));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
executeRun(db) {
|
executeRun(db) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
(0,_log_mjs__WEBPACK_IMPORTED_MODULE_2__.log)(this.sql);
|
(0,_log_mjs__WEBPACK_IMPORTED_MODULE_2__.log)(this.sql);
|
||||||
db.run(this.sql, ...this.args, function (err) {
|
db.get(this.sql, ...this.args, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
reject(_node_adapter_error_mjs__WEBPACK_IMPORTED_MODULE_0__.NodeAdapterError.from(err));
|
reject(_node_adapter_error_mjs__WEBPACK_IMPORTED_MODULE_0__.NodeAdapterError.from(err));
|
||||||
return;
|
return;
|
||||||
|
File diff suppressed because one or more lines are too long
@ -22,17 +22,41 @@ export class QueryWrapper {
|
|||||||
execute(db) {
|
execute(db) {
|
||||||
if (this.isAnyOf("INSERT", "UPDATE", "DELETE")) {
|
if (this.isAnyOf("INSERT", "UPDATE", "DELETE")) {
|
||||||
return this.executeRun(db);
|
return this.executeRun(db);
|
||||||
|
} else if (this.isAnyOf("PRAGMA")) {
|
||||||
|
return this.executeGet(db);
|
||||||
} else {
|
} else {
|
||||||
return this.executeAll(db);
|
return this.executeAll(db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
executeGet(db) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const self = this;
|
||||||
|
|
||||||
|
log(this.sql);
|
||||||
|
db.get(this.sql, ...this.args, function (err, row) {
|
||||||
|
if (err) {
|
||||||
|
reject(NodeAdapterError.from(err));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = {};
|
||||||
|
|
||||||
|
if (row) {
|
||||||
|
result.rows = [row];
|
||||||
|
}
|
||||||
|
|
||||||
|
resolve(ResponseWrapper.success(result));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
executeRun(db) {
|
executeRun(db) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
log(this.sql);
|
log(this.sql);
|
||||||
db.run(this.sql, ...this.args, function (err) {
|
db.get(this.sql, ...this.args, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
reject(NodeAdapterError.from(err));
|
reject(NodeAdapterError.from(err));
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user