@sqb/connect 4.8.2 → 4.9.0
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/cjs/client/cursor.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.Cursor = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
6
6
|
const doublylinked_1 = tslib_1.__importDefault(require("doublylinked"));
|
|
7
|
-
const
|
|
7
|
+
const power_tasks_1 = require("power-tasks");
|
|
8
8
|
const putil_varhelpers_1 = require("putil-varhelpers");
|
|
9
9
|
const strict_typed_events_1 = require("strict-typed-events");
|
|
10
10
|
const cursor_stream_js_1 = require("./cursor-stream.js");
|
|
@@ -16,7 +16,7 @@ class Cursor extends (0, strict_typed_events_1.TypedEventEmitterClass)(strict_ty
|
|
|
16
16
|
_prefetchRows;
|
|
17
17
|
_request;
|
|
18
18
|
_intlcur;
|
|
19
|
-
_taskQueue = new
|
|
19
|
+
_taskQueue = new power_tasks_1.TaskQueue();
|
|
20
20
|
_fetchCache = new doublylinked_1.default();
|
|
21
21
|
_rowNum = 0;
|
|
22
22
|
_fetchedAll = false;
|
|
@@ -219,7 +219,7 @@ class Cursor extends (0, strict_typed_events_1.TypedEventEmitterClass)(strict_ty
|
|
|
219
219
|
return;
|
|
220
220
|
await _this._fetchRows();
|
|
221
221
|
}
|
|
222
|
-
});
|
|
222
|
+
}).toPromise();
|
|
223
223
|
if (!silent)
|
|
224
224
|
this.emit('move', this.row, this._rowNum);
|
|
225
225
|
return this._rowNum;
|
|
@@ -4,7 +4,7 @@ exports.SqbConnection = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const assert_1 = tslib_1.__importDefault(require("assert"));
|
|
6
6
|
const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
7
|
-
const
|
|
7
|
+
const power_tasks_1 = require("power-tasks");
|
|
8
8
|
const putil_varhelpers_1 = require("putil-varhelpers");
|
|
9
9
|
const strict_typed_events_1 = require("strict-typed-events");
|
|
10
10
|
const builder_1 = require("@sqb/builder");
|
|
@@ -16,7 +16,7 @@ const debug = (0, debug_1.default)('sqb:connection');
|
|
|
16
16
|
class SqbConnection extends (0, strict_typed_events_1.TypedEventEmitterClass)(strict_typed_events_1.AsyncEventEmitter) {
|
|
17
17
|
client;
|
|
18
18
|
_intlcon;
|
|
19
|
-
_tasks = new
|
|
19
|
+
_tasks = new power_tasks_1.TaskQueue();
|
|
20
20
|
_options;
|
|
21
21
|
_inTransaction = false;
|
|
22
22
|
_refCount = 1;
|
|
@@ -90,7 +90,7 @@ class SqbConnection extends (0, strict_typed_events_1.TypedEventEmitterClass)(st
|
|
|
90
90
|
async execute(query, options) {
|
|
91
91
|
if (!this._intlcon)
|
|
92
92
|
throw new Error(`Can't execute query, because connection is released`);
|
|
93
|
-
return this._tasks.enqueue(() => this._execute(query, options));
|
|
93
|
+
return this._tasks.enqueue(() => this._execute(query, options)).toPromise();
|
|
94
94
|
}
|
|
95
95
|
getRepository(entity, opts) {
|
|
96
96
|
let ctor;
|
|
@@ -264,9 +264,11 @@ class SqbConnection extends (0, strict_typed_events_1.TypedEventEmitterClass)(st
|
|
|
264
264
|
if (query.listenerCount('fetch'))
|
|
265
265
|
request.fetchHooks = query.listeners('fetch');
|
|
266
266
|
}
|
|
267
|
-
else
|
|
268
|
-
|
|
269
|
-
|
|
267
|
+
else { // noinspection SuspiciousTypeOfGuard
|
|
268
|
+
if (typeof query === 'string') {
|
|
269
|
+
request.sql = query;
|
|
270
|
+
request.params = options.params;
|
|
271
|
+
}
|
|
270
272
|
}
|
|
271
273
|
// @ts-ignore
|
|
272
274
|
if (!request.sql)
|
package/esm/client/cursor.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _debug from 'debug';
|
|
2
2
|
import DoublyLinked from 'doublylinked';
|
|
3
|
-
import TaskQueue from '
|
|
3
|
+
import { TaskQueue } from 'power-tasks';
|
|
4
4
|
import { coerceToInt } from 'putil-varhelpers';
|
|
5
5
|
import { AsyncEventEmitter, TypedEventEmitterClass } from 'strict-typed-events';
|
|
6
6
|
import { CursorStream } from './cursor-stream.js';
|
|
@@ -215,7 +215,7 @@ export class Cursor extends TypedEventEmitterClass(AsyncEventEmitter) {
|
|
|
215
215
|
return;
|
|
216
216
|
await _this._fetchRows();
|
|
217
217
|
}
|
|
218
|
-
});
|
|
218
|
+
}).toPromise();
|
|
219
219
|
if (!silent)
|
|
220
220
|
this.emit('move', this.row, this._rowNum);
|
|
221
221
|
return this._rowNum;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import assert from 'assert';
|
|
2
2
|
import _debug from 'debug';
|
|
3
|
-
import TaskQueue from '
|
|
3
|
+
import { TaskQueue } from 'power-tasks';
|
|
4
4
|
import { coalesce, coerceToBoolean, coerceToInt, coerceToString } from "putil-varhelpers";
|
|
5
5
|
import { AsyncEventEmitter, TypedEventEmitterClass } from 'strict-typed-events';
|
|
6
6
|
import { classes } from '@sqb/builder';
|
|
@@ -86,7 +86,7 @@ export class SqbConnection extends TypedEventEmitterClass(AsyncEventEmitter) {
|
|
|
86
86
|
async execute(query, options) {
|
|
87
87
|
if (!this._intlcon)
|
|
88
88
|
throw new Error(`Can't execute query, because connection is released`);
|
|
89
|
-
return this._tasks.enqueue(() => this._execute(query, options));
|
|
89
|
+
return this._tasks.enqueue(() => this._execute(query, options)).toPromise();
|
|
90
90
|
}
|
|
91
91
|
getRepository(entity, opts) {
|
|
92
92
|
let ctor;
|
|
@@ -260,9 +260,11 @@ export class SqbConnection extends TypedEventEmitterClass(AsyncEventEmitter) {
|
|
|
260
260
|
if (query.listenerCount('fetch'))
|
|
261
261
|
request.fetchHooks = query.listeners('fetch');
|
|
262
262
|
}
|
|
263
|
-
else
|
|
264
|
-
|
|
265
|
-
|
|
263
|
+
else { // noinspection SuspiciousTypeOfGuard
|
|
264
|
+
if (typeof query === 'string') {
|
|
265
|
+
request.sql = query;
|
|
266
|
+
request.params = options.params;
|
|
267
|
+
}
|
|
266
268
|
}
|
|
267
269
|
// @ts-ignore
|
|
268
270
|
if (!request.sql)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqb/connect",
|
|
3
3
|
"description": "Multi-dialect database connection framework written with TypeScript",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.9.0",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Eray Hanoglu <e.hanoglu@panates.com>",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"debug": "^4.3.4",
|
|
33
33
|
"lightning-pool": "^4.2.1",
|
|
34
34
|
"lodash": "^4.17.21",
|
|
35
|
+
"power-tasks": "^1.6.4",
|
|
35
36
|
"putil-isplainobject": "^1.1.5",
|
|
36
37
|
"putil-merge": "^3.10.3",
|
|
37
38
|
"putil-promisify": "^1.10.0",
|
|
38
|
-
"putil-taskqueue": "^2.5.5",
|
|
39
39
|
"putil-varhelpers": "^1.6.5",
|
|
40
40
|
"reflect-metadata": "^0.1.13",
|
|
41
41
|
"strict-typed-events": "^2.3.1",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@types/lodash": "^4.14.194"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"@sqb/builder": "^4.
|
|
49
|
+
"@sqb/builder": "^4.9.0"
|
|
50
50
|
},
|
|
51
51
|
"type": "module",
|
|
52
52
|
"types": "esm/index.d.ts",
|