query-core 0.1.20 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/services.js +29 -1
- package/package.json +1 -1
- package/src/services.ts +28 -1
package/lib/services.js
CHANGED
|
@@ -145,8 +145,36 @@ var LogManager = (function () {
|
|
|
145
145
|
return this.db.param(i);
|
|
146
146
|
};
|
|
147
147
|
LogManager.prototype.exec = function (sql, args, ctx) {
|
|
148
|
+
var _this = this;
|
|
148
149
|
var t1 = new Date();
|
|
149
|
-
return this.db.exec(sql, args, ctx)
|
|
150
|
+
return this.db.exec(sql, args, ctx).then(function (v) {
|
|
151
|
+
setTimeout(function () {
|
|
152
|
+
if (_this.log) {
|
|
153
|
+
var d = diff(t1);
|
|
154
|
+
var obj = {};
|
|
155
|
+
if (_this.sql.length > 0) {
|
|
156
|
+
obj[_this.sql] = getString(sql, args);
|
|
157
|
+
}
|
|
158
|
+
if (_this.return.length > 0) {
|
|
159
|
+
obj[_this.return] = v;
|
|
160
|
+
}
|
|
161
|
+
obj[_this.duration] = d;
|
|
162
|
+
_this.log('query', obj);
|
|
163
|
+
}
|
|
164
|
+
}, 0);
|
|
165
|
+
return v;
|
|
166
|
+
}).catch(function (er) {
|
|
167
|
+
setTimeout(function () {
|
|
168
|
+
var d = diff(t1);
|
|
169
|
+
var obj = {};
|
|
170
|
+
if (_this.sql.length > 0) {
|
|
171
|
+
obj[_this.sql] = getString(sql, args);
|
|
172
|
+
}
|
|
173
|
+
obj[_this.duration] = d;
|
|
174
|
+
_this.error('error query: ' + buildString(er));
|
|
175
|
+
}, 0);
|
|
176
|
+
throw er;
|
|
177
|
+
});
|
|
150
178
|
};
|
|
151
179
|
LogManager.prototype.execBatch = function (statements, firstSuccess, ctx) {
|
|
152
180
|
var _this = this;
|
package/package.json
CHANGED
package/src/services.ts
CHANGED
|
@@ -181,7 +181,34 @@ export class LogManager implements ExtManager {
|
|
|
181
181
|
}
|
|
182
182
|
exec(sql: string, args?: any[], ctx?: any): Promise<number> {
|
|
183
183
|
const t1 = new Date();
|
|
184
|
-
return this.db.exec(sql, args, ctx)
|
|
184
|
+
return this.db.exec(sql, args, ctx).then(v => {
|
|
185
|
+
setTimeout(() => {
|
|
186
|
+
if (this.log) {
|
|
187
|
+
const d = diff(t1);
|
|
188
|
+
const obj: SimpleMap = {} ;
|
|
189
|
+
if (this.sql.length > 0) {
|
|
190
|
+
obj[this.sql] = getString(sql, args);
|
|
191
|
+
}
|
|
192
|
+
if (this.return.length > 0) {
|
|
193
|
+
obj[this.return] = v;
|
|
194
|
+
}
|
|
195
|
+
obj[this.duration] = d;
|
|
196
|
+
this.log('query', obj);
|
|
197
|
+
}
|
|
198
|
+
}, 0);
|
|
199
|
+
return v;
|
|
200
|
+
}).catch(er => {
|
|
201
|
+
setTimeout(() => {
|
|
202
|
+
const d = diff(t1);
|
|
203
|
+
const obj: SimpleMap = {};
|
|
204
|
+
if (this.sql.length > 0) {
|
|
205
|
+
obj[this.sql] = getString(sql, args);
|
|
206
|
+
}
|
|
207
|
+
obj[this.duration] = d;
|
|
208
|
+
this.error('error query: ' + buildString(er));
|
|
209
|
+
}, 0);
|
|
210
|
+
throw er;
|
|
211
|
+
});
|
|
185
212
|
}
|
|
186
213
|
execBatch(statements: Statement[], firstSuccess?: boolean, ctx?: any): Promise<number> {
|
|
187
214
|
const t1 = new Date();
|