@sqb/connect 4.20.0 → 4.20.1
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-stream.js +5 -2
- package/cjs/client/cursor.js +12 -5
- package/cjs/client/extensions.js +1 -1
- package/cjs/client/field-info-map.js +2 -0
- package/cjs/client/sqb-client.js +4 -1
- package/cjs/client/sqb-connection.js +16 -4
- package/cjs/client/sqb-error.js +16 -0
- package/cjs/index.js +1 -0
- package/cjs/orm/base-entity.js +1 -0
- package/cjs/orm/commands/find.command.js +11 -7
- package/cjs/orm/commands/row-converter.js +4 -1
- package/cjs/orm/model/association-node.js +3 -0
- package/cjs/orm/model/association.js +13 -0
- package/cjs/orm/model/link-chain.js +3 -0
- package/cjs/orm/repository.class.js +3 -0
- package/cjs/orm/util/parse-fields-projection.js +2 -0
- package/esm/client/cursor-stream.js +5 -2
- package/esm/client/cursor.js +12 -5
- package/esm/client/extensions.js +1 -1
- package/esm/client/field-info-map.js +2 -0
- package/esm/client/sqb-client.js +4 -1
- package/esm/client/sqb-connection.js +16 -4
- package/esm/client/sqb-error.js +12 -0
- package/esm/index.js +1 -0
- package/esm/orm/base-entity.js +1 -0
- package/esm/orm/commands/find.command.js +11 -7
- package/esm/orm/commands/row-converter.js +4 -1
- package/esm/orm/model/association-node.js +3 -0
- package/esm/orm/model/association.js +13 -0
- package/esm/orm/model/link-chain.js +3 -0
- package/esm/orm/repository.class.js +3 -0
- package/esm/orm/util/parse-fields-projection.js +2 -0
- package/package.json +2 -2
- package/types/client/sqb-error.d.ts +9 -0
- package/types/index.d.cts +1 -0
- package/types/index.d.ts +1 -0
|
@@ -7,10 +7,13 @@ const stream_1 = require("stream");
|
|
|
7
7
|
const inspect = Symbol.for('nodejs.util.inspect.custom');
|
|
8
8
|
const debug = (0, debug_1.default)('sqb:cursorstream');
|
|
9
9
|
class CursorStream extends stream_1.Readable {
|
|
10
|
+
_cursor;
|
|
11
|
+
_objectMode;
|
|
12
|
+
_limit;
|
|
13
|
+
_rowNum = -1;
|
|
14
|
+
_eof = false;
|
|
10
15
|
constructor(cursor, options) {
|
|
11
16
|
super(options);
|
|
12
|
-
this._rowNum = -1;
|
|
13
|
-
this._eof = false;
|
|
14
17
|
this._cursor = cursor;
|
|
15
18
|
this._objectMode = options?.objectMode;
|
|
16
19
|
this._limit = options?.limit || Number.MAX_SAFE_INTEGER;
|
package/cjs/client/cursor.js
CHANGED
|
@@ -11,13 +11,20 @@ const cursor_stream_js_1 = require("./cursor-stream.js");
|
|
|
11
11
|
const helpers_js_1 = require("./helpers.js");
|
|
12
12
|
const debug = (0, debug_1.default)('sqb:cursor');
|
|
13
13
|
class Cursor extends (0, strict_typed_events_1.TypedEventEmitterClass)(strict_typed_events_1.AsyncEventEmitter) {
|
|
14
|
+
_connection;
|
|
15
|
+
_fields;
|
|
16
|
+
_prefetchRows;
|
|
17
|
+
_request;
|
|
18
|
+
_intlcur;
|
|
19
|
+
_taskQueue = new power_tasks_1.TaskQueue();
|
|
20
|
+
_fetchCache = new doublylinked_1.default();
|
|
21
|
+
_rowNum = 0;
|
|
22
|
+
_fetchedAll = false;
|
|
23
|
+
_fetchedRows = 0;
|
|
24
|
+
_row;
|
|
25
|
+
_cache;
|
|
14
26
|
constructor(connection, fields, adapterCursor, request) {
|
|
15
27
|
super();
|
|
16
|
-
this._taskQueue = new power_tasks_1.TaskQueue();
|
|
17
|
-
this._fetchCache = new doublylinked_1.default();
|
|
18
|
-
this._rowNum = 0;
|
|
19
|
-
this._fetchedAll = false;
|
|
20
|
-
this._fetchedRows = 0;
|
|
21
28
|
this._connection = connection;
|
|
22
29
|
this._intlcur = adapterCursor;
|
|
23
30
|
this._fields = fields;
|
package/cjs/client/extensions.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AdapterRegistry = void 0;
|
|
4
4
|
class AdapterRegistry {
|
|
5
|
+
static adapters = [];
|
|
5
6
|
static get size() {
|
|
6
7
|
return this.adapters.length;
|
|
7
8
|
}
|
|
@@ -38,4 +39,3 @@ class AdapterRegistry {
|
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
exports.AdapterRegistry = AdapterRegistry;
|
|
41
|
-
AdapterRegistry.adapters = [];
|
package/cjs/client/sqb-client.js
CHANGED
|
@@ -13,9 +13,12 @@ const sqb_connection_js_1 = require("./sqb-connection.js");
|
|
|
13
13
|
const debug = (0, debug_1.default)('sqb:client');
|
|
14
14
|
const inspect = Symbol.for('nodejs.util.inspect.custom');
|
|
15
15
|
class SqbClient extends (0, strict_typed_events_1.TypedEventEmitterClass)(strict_typed_events_1.AsyncEventEmitter) {
|
|
16
|
+
_adapter;
|
|
17
|
+
_pool;
|
|
18
|
+
_defaults;
|
|
19
|
+
_entities = {};
|
|
16
20
|
constructor(config) {
|
|
17
21
|
super();
|
|
18
|
-
this._entities = {};
|
|
19
22
|
if (!(config && typeof config === 'object'))
|
|
20
23
|
throw new TypeError('Configuration object required');
|
|
21
24
|
let adapter;
|
|
@@ -12,14 +12,18 @@ const entity_metadata_js_1 = require("../orm/model/entity-metadata.js");
|
|
|
12
12
|
const repository_class_js_1 = require("../orm/repository.class.js");
|
|
13
13
|
const cursor_js_1 = require("./cursor.js");
|
|
14
14
|
const helpers_js_1 = require("./helpers.js");
|
|
15
|
+
const sqb_error_js_1 = require("./sqb-error.js");
|
|
15
16
|
const debug = (0, debug_1.default)('sqb:connection');
|
|
16
17
|
class SqbConnection extends (0, strict_typed_events_1.TypedEventEmitterClass)(strict_typed_events_1.AsyncEventEmitter) {
|
|
18
|
+
client;
|
|
19
|
+
_intlcon;
|
|
20
|
+
_tasks = new power_tasks_1.TaskQueue();
|
|
21
|
+
_options;
|
|
22
|
+
_inTransaction = false;
|
|
23
|
+
_refCount = 1;
|
|
17
24
|
constructor(client, adapterConnection, options) {
|
|
18
25
|
super();
|
|
19
26
|
this.client = client;
|
|
20
|
-
this._tasks = new power_tasks_1.TaskQueue();
|
|
21
|
-
this._inTransaction = false;
|
|
22
|
-
this._refCount = 1;
|
|
23
27
|
this._intlcon = adapterConnection;
|
|
24
28
|
this._options = options || {};
|
|
25
29
|
}
|
|
@@ -120,9 +124,10 @@ class SqbConnection extends (0, strict_typed_events_1.TypedEventEmitterClass)(st
|
|
|
120
124
|
assert_1.default.ok(this._intlcon, `Can't execute query, because connection is released`);
|
|
121
125
|
const intlcon = this._intlcon;
|
|
122
126
|
this.retain();
|
|
127
|
+
let request;
|
|
123
128
|
try {
|
|
124
129
|
const startTime = Date.now();
|
|
125
|
-
|
|
130
|
+
request = this._prepareQueryRequest(query, options);
|
|
126
131
|
debug('[%s] execute | %o', this.sessionId, request);
|
|
127
132
|
this.emit('execute', request);
|
|
128
133
|
// Call execute hooks
|
|
@@ -163,6 +168,13 @@ class SqbConnection extends (0, strict_typed_events_1.TypedEventEmitterClass)(st
|
|
|
163
168
|
result.rowsAffected = response.rowsAffected;
|
|
164
169
|
return result;
|
|
165
170
|
}
|
|
171
|
+
catch (e) {
|
|
172
|
+
const error = new sqb_error_js_1.SQBError(e.message, e);
|
|
173
|
+
error.query = query;
|
|
174
|
+
error.queryOptions = options;
|
|
175
|
+
error.request = request;
|
|
176
|
+
this.emit('error', e);
|
|
177
|
+
}
|
|
166
178
|
finally {
|
|
167
179
|
this.release();
|
|
168
180
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SQBError = void 0;
|
|
4
|
+
class SQBError extends Error {
|
|
5
|
+
cause;
|
|
6
|
+
query;
|
|
7
|
+
queryOptions;
|
|
8
|
+
request;
|
|
9
|
+
constructor(message, cause) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.cause = cause;
|
|
12
|
+
if (cause)
|
|
13
|
+
this.stack = cause.stack;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.SQBError = SQBError;
|
package/cjs/index.js
CHANGED
|
@@ -8,6 +8,7 @@ tslib_1.__exportStar(require("./client/cursor.js"), exports);
|
|
|
8
8
|
tslib_1.__exportStar(require("./client/extensions.js"), exports);
|
|
9
9
|
tslib_1.__exportStar(require("./client/sqb-client.js"), exports);
|
|
10
10
|
tslib_1.__exportStar(require("./client/sqb-connection.js"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./client/sqb-error.js"), exports);
|
|
11
12
|
tslib_1.__exportStar(require("./client/types.js"), exports);
|
|
12
13
|
tslib_1.__exportStar(require("./orm/backward.js"), exports);
|
|
13
14
|
tslib_1.__exportStar(require("./orm/base-entity.js"), exports);
|
package/cjs/orm/base-entity.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.BaseEntity = void 0;
|
|
|
4
4
|
const entity_decorator_js_1 = require("./decorators/entity.decorator.js");
|
|
5
5
|
const orm_const_js_1 = require("./orm.const.js");
|
|
6
6
|
class BaseEntity {
|
|
7
|
+
[orm_const_js_1.REPOSITORY_KEY];
|
|
7
8
|
constructor(partial) {
|
|
8
9
|
const fields = entity_decorator_js_1.Entity.getColumnFieldNames(Object.getPrototypeOf(this).constructor);
|
|
9
10
|
if (fields && partial) {
|
|
@@ -11,14 +11,18 @@ const command_helper_js_1 = require("./command.helper.js");
|
|
|
11
11
|
const row_converter_js_1 = require("./row-converter.js");
|
|
12
12
|
const SORT_ORDER_PATTERN = /^([-+])?(.*)$/;
|
|
13
13
|
class FindCommand {
|
|
14
|
+
maxEagerFetch = 100000;
|
|
15
|
+
maxSubQueries = 5;
|
|
16
|
+
mainEntity;
|
|
17
|
+
resultEntity;
|
|
18
|
+
converter;
|
|
19
|
+
mainAlias = 'T';
|
|
20
|
+
resultAlias = 'T';
|
|
21
|
+
_joins = [];
|
|
22
|
+
_selectColumns = {};
|
|
23
|
+
_filter = (0, builder_1.And)();
|
|
24
|
+
_sort;
|
|
14
25
|
constructor(selectEntity, outputEntity) {
|
|
15
|
-
this.maxEagerFetch = 100000;
|
|
16
|
-
this.maxSubQueries = 5;
|
|
17
|
-
this.mainAlias = 'T';
|
|
18
|
-
this.resultAlias = 'T';
|
|
19
|
-
this._joins = [];
|
|
20
|
-
this._selectColumns = {};
|
|
21
|
-
this._filter = (0, builder_1.And)();
|
|
22
26
|
this.mainEntity = selectEntity;
|
|
23
27
|
this.resultEntity = outputEntity;
|
|
24
28
|
this.converter = new row_converter_js_1.RowConverter(outputEntity.ctor);
|
|
@@ -6,10 +6,13 @@ const isValueProperty = (prop) => prop.fieldAlias && !prop.converter;
|
|
|
6
6
|
const isObjectProperty = (prop) => prop.converter && !prop.findCommand;
|
|
7
7
|
const isNestedProperty = (prop) => prop.converter && prop.findCommand;
|
|
8
8
|
class RowConverter {
|
|
9
|
+
resultType;
|
|
10
|
+
parent;
|
|
11
|
+
_properties = {};
|
|
12
|
+
_propertyKeys;
|
|
9
13
|
constructor(resultType, parent) {
|
|
10
14
|
this.resultType = resultType;
|
|
11
15
|
this.parent = parent;
|
|
12
|
-
this._properties = {};
|
|
13
16
|
}
|
|
14
17
|
addValueProperty(args) {
|
|
15
18
|
this._propertyKeys = undefined;
|
|
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AssociationNode = void 0;
|
|
4
4
|
const association_js_1 = require("./association.js");
|
|
5
5
|
class AssociationNode extends association_js_1.Association {
|
|
6
|
+
prior;
|
|
7
|
+
next;
|
|
8
|
+
conditions;
|
|
6
9
|
getFirst() {
|
|
7
10
|
let l = this;
|
|
8
11
|
while (l.prior)
|
|
@@ -5,6 +5,19 @@ const putil_varhelpers_1 = require("putil-varhelpers");
|
|
|
5
5
|
const orm_helper_js_1 = require("../util/orm.helper.js");
|
|
6
6
|
const entity_metadata_js_1 = require("./entity-metadata.js");
|
|
7
7
|
class Association {
|
|
8
|
+
_resolved;
|
|
9
|
+
_source; // cached value
|
|
10
|
+
_target; // cached value
|
|
11
|
+
_sourceKey; // cached value
|
|
12
|
+
_targetKey; // cached value
|
|
13
|
+
_sourceProperty;
|
|
14
|
+
_targetProperty;
|
|
15
|
+
name;
|
|
16
|
+
source;
|
|
17
|
+
target;
|
|
18
|
+
sourceKey;
|
|
19
|
+
targetKey;
|
|
20
|
+
many;
|
|
8
21
|
constructor(name, args) {
|
|
9
22
|
this.name = name;
|
|
10
23
|
this.source = args.source;
|
|
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.LinkChain = void 0;
|
|
4
4
|
const association_node_js_1 = require("./association-node.js");
|
|
5
5
|
class LinkChain {
|
|
6
|
+
target;
|
|
7
|
+
first;
|
|
8
|
+
current;
|
|
6
9
|
constructor(target, targetKey, sourceKey, many) {
|
|
7
10
|
this.target = target;
|
|
8
11
|
this.first = this.current = new association_node_js_1.AssociationNode('', {
|
|
@@ -15,6 +15,9 @@ const extract_keyvalues_js_1 = require("./util/extract-keyvalues.js");
|
|
|
15
15
|
* @template T - The data type class type of the record
|
|
16
16
|
*/
|
|
17
17
|
class Repository extends (0, strict_typed_events_1.TypedEventEmitterClass)(strict_typed_events_1.AsyncEventEmitter) {
|
|
18
|
+
_executor;
|
|
19
|
+
_entity;
|
|
20
|
+
_schema;
|
|
18
21
|
constructor(entityDef, executor, schema) {
|
|
19
22
|
super();
|
|
20
23
|
this._executor = executor;
|
|
@@ -10,6 +10,8 @@ class FieldsProjection {
|
|
|
10
10
|
exports.FieldsProjection = FieldsProjection;
|
|
11
11
|
(function (FieldsProjection) {
|
|
12
12
|
class Item {
|
|
13
|
+
sign;
|
|
14
|
+
projection;
|
|
13
15
|
}
|
|
14
16
|
FieldsProjection.Item = Item;
|
|
15
17
|
})(FieldsProjection || (exports.FieldsProjection = FieldsProjection = {}));
|
|
@@ -3,10 +3,13 @@ import { Readable } from 'stream';
|
|
|
3
3
|
const inspect = Symbol.for('nodejs.util.inspect.custom');
|
|
4
4
|
const debug = _debug('sqb:cursorstream');
|
|
5
5
|
export class CursorStream extends Readable {
|
|
6
|
+
_cursor;
|
|
7
|
+
_objectMode;
|
|
8
|
+
_limit;
|
|
9
|
+
_rowNum = -1;
|
|
10
|
+
_eof = false;
|
|
6
11
|
constructor(cursor, options) {
|
|
7
12
|
super(options);
|
|
8
|
-
this._rowNum = -1;
|
|
9
|
-
this._eof = false;
|
|
10
13
|
this._cursor = cursor;
|
|
11
14
|
this._objectMode = options?.objectMode;
|
|
12
15
|
this._limit = options?.limit || Number.MAX_SAFE_INTEGER;
|
package/esm/client/cursor.js
CHANGED
|
@@ -7,13 +7,20 @@ import { CursorStream } from './cursor-stream.js';
|
|
|
7
7
|
import { callFetchHooks, normalizeRowsToArrayRows, normalizeRowsToObjectRows, } from './helpers.js';
|
|
8
8
|
const debug = _debug('sqb:cursor');
|
|
9
9
|
export class Cursor extends TypedEventEmitterClass(AsyncEventEmitter) {
|
|
10
|
+
_connection;
|
|
11
|
+
_fields;
|
|
12
|
+
_prefetchRows;
|
|
13
|
+
_request;
|
|
14
|
+
_intlcur;
|
|
15
|
+
_taskQueue = new TaskQueue();
|
|
16
|
+
_fetchCache = new DoublyLinked();
|
|
17
|
+
_rowNum = 0;
|
|
18
|
+
_fetchedAll = false;
|
|
19
|
+
_fetchedRows = 0;
|
|
20
|
+
_row;
|
|
21
|
+
_cache;
|
|
10
22
|
constructor(connection, fields, adapterCursor, request) {
|
|
11
23
|
super();
|
|
12
|
-
this._taskQueue = new TaskQueue();
|
|
13
|
-
this._fetchCache = new DoublyLinked();
|
|
14
|
-
this._rowNum = 0;
|
|
15
|
-
this._fetchedAll = false;
|
|
16
|
-
this._fetchedRows = 0;
|
|
17
24
|
this._connection = connection;
|
|
18
25
|
this._intlcur = adapterCursor;
|
|
19
26
|
this._fields = fields;
|
package/esm/client/extensions.js
CHANGED
package/esm/client/sqb-client.js
CHANGED
|
@@ -9,9 +9,12 @@ import { SqbConnection } from './sqb-connection.js';
|
|
|
9
9
|
const debug = _debug('sqb:client');
|
|
10
10
|
const inspect = Symbol.for('nodejs.util.inspect.custom');
|
|
11
11
|
export class SqbClient extends TypedEventEmitterClass(AsyncEventEmitter) {
|
|
12
|
+
_adapter;
|
|
13
|
+
_pool;
|
|
14
|
+
_defaults;
|
|
15
|
+
_entities = {};
|
|
12
16
|
constructor(config) {
|
|
13
17
|
super();
|
|
14
|
-
this._entities = {};
|
|
15
18
|
if (!(config && typeof config === 'object'))
|
|
16
19
|
throw new TypeError('Configuration object required');
|
|
17
20
|
let adapter;
|
|
@@ -8,14 +8,18 @@ import { EntityMetadata } from '../orm/model/entity-metadata.js';
|
|
|
8
8
|
import { Repository } from '../orm/repository.class.js';
|
|
9
9
|
import { Cursor } from './cursor.js';
|
|
10
10
|
import { callFetchHooks, normalizeRowsToArrayRows, normalizeRowsToObjectRows, wrapAdapterFields, } from './helpers.js';
|
|
11
|
+
import { SQBError } from './sqb-error.js';
|
|
11
12
|
const debug = _debug('sqb:connection');
|
|
12
13
|
export class SqbConnection extends TypedEventEmitterClass(AsyncEventEmitter) {
|
|
14
|
+
client;
|
|
15
|
+
_intlcon;
|
|
16
|
+
_tasks = new TaskQueue();
|
|
17
|
+
_options;
|
|
18
|
+
_inTransaction = false;
|
|
19
|
+
_refCount = 1;
|
|
13
20
|
constructor(client, adapterConnection, options) {
|
|
14
21
|
super();
|
|
15
22
|
this.client = client;
|
|
16
|
-
this._tasks = new TaskQueue();
|
|
17
|
-
this._inTransaction = false;
|
|
18
|
-
this._refCount = 1;
|
|
19
23
|
this._intlcon = adapterConnection;
|
|
20
24
|
this._options = options || {};
|
|
21
25
|
}
|
|
@@ -116,9 +120,10 @@ export class SqbConnection extends TypedEventEmitterClass(AsyncEventEmitter) {
|
|
|
116
120
|
assert.ok(this._intlcon, `Can't execute query, because connection is released`);
|
|
117
121
|
const intlcon = this._intlcon;
|
|
118
122
|
this.retain();
|
|
123
|
+
let request;
|
|
119
124
|
try {
|
|
120
125
|
const startTime = Date.now();
|
|
121
|
-
|
|
126
|
+
request = this._prepareQueryRequest(query, options);
|
|
122
127
|
debug('[%s] execute | %o', this.sessionId, request);
|
|
123
128
|
this.emit('execute', request);
|
|
124
129
|
// Call execute hooks
|
|
@@ -159,6 +164,13 @@ export class SqbConnection extends TypedEventEmitterClass(AsyncEventEmitter) {
|
|
|
159
164
|
result.rowsAffected = response.rowsAffected;
|
|
160
165
|
return result;
|
|
161
166
|
}
|
|
167
|
+
catch (e) {
|
|
168
|
+
const error = new SQBError(e.message, e);
|
|
169
|
+
error.query = query;
|
|
170
|
+
error.queryOptions = options;
|
|
171
|
+
error.request = request;
|
|
172
|
+
this.emit('error', e);
|
|
173
|
+
}
|
|
162
174
|
finally {
|
|
163
175
|
this.release();
|
|
164
176
|
}
|
package/esm/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export * from './client/cursor.js';
|
|
|
4
4
|
export * from './client/extensions.js';
|
|
5
5
|
export * from './client/sqb-client.js';
|
|
6
6
|
export * from './client/sqb-connection.js';
|
|
7
|
+
export * from './client/sqb-error.js';
|
|
7
8
|
export * from './client/types.js';
|
|
8
9
|
export * from './orm/backward.js';
|
|
9
10
|
export * from './orm/base-entity.js';
|
package/esm/orm/base-entity.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Entity } from './decorators/entity.decorator.js';
|
|
2
2
|
import { REPOSITORY_KEY } from './orm.const.js';
|
|
3
3
|
export class BaseEntity {
|
|
4
|
+
[REPOSITORY_KEY];
|
|
4
5
|
constructor(partial) {
|
|
5
6
|
const fields = Entity.getColumnFieldNames(Object.getPrototypeOf(this).constructor);
|
|
6
7
|
if (fields && partial) {
|
|
@@ -8,14 +8,18 @@ import { joinAssociationGetLast, prepareFilter, } from './command.helper.js';
|
|
|
8
8
|
import { RowConverter } from './row-converter.js';
|
|
9
9
|
const SORT_ORDER_PATTERN = /^([-+])?(.*)$/;
|
|
10
10
|
export class FindCommand {
|
|
11
|
+
maxEagerFetch = 100000;
|
|
12
|
+
maxSubQueries = 5;
|
|
13
|
+
mainEntity;
|
|
14
|
+
resultEntity;
|
|
15
|
+
converter;
|
|
16
|
+
mainAlias = 'T';
|
|
17
|
+
resultAlias = 'T';
|
|
18
|
+
_joins = [];
|
|
19
|
+
_selectColumns = {};
|
|
20
|
+
_filter = And();
|
|
21
|
+
_sort;
|
|
11
22
|
constructor(selectEntity, outputEntity) {
|
|
12
|
-
this.maxEagerFetch = 100000;
|
|
13
|
-
this.maxSubQueries = 5;
|
|
14
|
-
this.mainAlias = 'T';
|
|
15
|
-
this.resultAlias = 'T';
|
|
16
|
-
this._joins = [];
|
|
17
|
-
this._selectColumns = {};
|
|
18
|
-
this._filter = And();
|
|
19
23
|
this.mainEntity = selectEntity;
|
|
20
24
|
this.resultEntity = outputEntity;
|
|
21
25
|
this.converter = new RowConverter(outputEntity.ctor);
|
|
@@ -3,10 +3,13 @@ const isValueProperty = (prop) => prop.fieldAlias && !prop.converter;
|
|
|
3
3
|
const isObjectProperty = (prop) => prop.converter && !prop.findCommand;
|
|
4
4
|
const isNestedProperty = (prop) => prop.converter && prop.findCommand;
|
|
5
5
|
export class RowConverter {
|
|
6
|
+
resultType;
|
|
7
|
+
parent;
|
|
8
|
+
_properties = {};
|
|
9
|
+
_propertyKeys;
|
|
6
10
|
constructor(resultType, parent) {
|
|
7
11
|
this.resultType = resultType;
|
|
8
12
|
this.parent = parent;
|
|
9
|
-
this._properties = {};
|
|
10
13
|
}
|
|
11
14
|
addValueProperty(args) {
|
|
12
15
|
this._propertyKeys = undefined;
|
|
@@ -2,6 +2,19 @@ import { camelCase } from 'putil-varhelpers';
|
|
|
2
2
|
import { resolveEntityMeta } from '../util/orm.helper.js';
|
|
3
3
|
import { EntityMetadata } from './entity-metadata.js';
|
|
4
4
|
export class Association {
|
|
5
|
+
_resolved;
|
|
6
|
+
_source; // cached value
|
|
7
|
+
_target; // cached value
|
|
8
|
+
_sourceKey; // cached value
|
|
9
|
+
_targetKey; // cached value
|
|
10
|
+
_sourceProperty;
|
|
11
|
+
_targetProperty;
|
|
12
|
+
name;
|
|
13
|
+
source;
|
|
14
|
+
target;
|
|
15
|
+
sourceKey;
|
|
16
|
+
targetKey;
|
|
17
|
+
many;
|
|
5
18
|
constructor(name, args) {
|
|
6
19
|
this.name = name;
|
|
7
20
|
this.source = args.source;
|
|
@@ -12,6 +12,9 @@ import { extractKeyValues } from './util/extract-keyvalues.js';
|
|
|
12
12
|
* @template T - The data type class type of the record
|
|
13
13
|
*/
|
|
14
14
|
export class Repository extends TypedEventEmitterClass(AsyncEventEmitter) {
|
|
15
|
+
_executor;
|
|
16
|
+
_entity;
|
|
17
|
+
_schema;
|
|
15
18
|
constructor(entityDef, executor, schema) {
|
|
16
19
|
super();
|
|
17
20
|
this._executor = executor;
|
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.20.
|
|
4
|
+
"version": "4.20.1",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"dependencies": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"tslib": "^2.8.1"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"@sqb/builder": "^4.20.
|
|
23
|
+
"@sqb/builder": "^4.20.1",
|
|
24
24
|
"reflect-metadata": "^0.2.2"
|
|
25
25
|
},
|
|
26
26
|
"type": "module",
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Query } from '@sqb/builder';
|
|
2
|
+
import { QueryExecuteOptions, QueryRequest } from './types.js';
|
|
3
|
+
export declare class SQBError extends Error {
|
|
4
|
+
cause?: Error;
|
|
5
|
+
query?: string | Query;
|
|
6
|
+
queryOptions?: QueryExecuteOptions;
|
|
7
|
+
request?: QueryRequest;
|
|
8
|
+
constructor(message: string, cause?: Error);
|
|
9
|
+
}
|
package/types/index.d.cts
CHANGED
|
@@ -4,6 +4,7 @@ export * from './client/cursor.js';
|
|
|
4
4
|
export * from './client/extensions.js';
|
|
5
5
|
export * from './client/sqb-client.js';
|
|
6
6
|
export * from './client/sqb-connection.js';
|
|
7
|
+
export * from './client/sqb-error.js';
|
|
7
8
|
export * from './client/types.js';
|
|
8
9
|
export * from './orm/backward.js';
|
|
9
10
|
export * from './orm/base-entity.js';
|
package/types/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from './client/cursor.js';
|
|
|
4
4
|
export * from './client/extensions.js';
|
|
5
5
|
export * from './client/sqb-client.js';
|
|
6
6
|
export * from './client/sqb-connection.js';
|
|
7
|
+
export * from './client/sqb-error.js';
|
|
7
8
|
export * from './client/types.js';
|
|
8
9
|
export * from './orm/backward.js';
|
|
9
10
|
export * from './orm/base-entity.js';
|