@sqb/connect 4.24.1 → 4.25.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/orm/commands/count.command.js +18 -2
- package/orm/commands/create.command.js +6 -2
- package/orm/commands/delete.command.js +18 -2
- package/orm/commands/find.command.d.ts +1 -1
- package/orm/commands/find.command.js +18 -2
- package/orm/commands/update.command.js +18 -2
- package/orm/repository.class.d.ts +21 -2
- package/package.json +2 -2
|
@@ -13,8 +13,24 @@ export class CountCommand {
|
|
|
13
13
|
await prepareFilter(entity, filter, where, 'T');
|
|
14
14
|
}
|
|
15
15
|
const query = Select(Count()).from(entity.tableName + ' T');
|
|
16
|
-
if (args.comment)
|
|
17
|
-
|
|
16
|
+
if (args.comment) {
|
|
17
|
+
if (Array.isArray(args.comment))
|
|
18
|
+
args.comment.forEach(c => query.comment(c));
|
|
19
|
+
else
|
|
20
|
+
query.comment(args.comment);
|
|
21
|
+
}
|
|
22
|
+
if (args.indexHint) {
|
|
23
|
+
if (Array.isArray(args.indexHint))
|
|
24
|
+
args.indexHint.forEach(c => query.indexHint(c));
|
|
25
|
+
else
|
|
26
|
+
query.indexHint(args.indexHint);
|
|
27
|
+
}
|
|
28
|
+
if (args.noIndexHint) {
|
|
29
|
+
if (Array.isArray(args.noIndexHint))
|
|
30
|
+
args.noIndexHint.forEach(c => query.noIndexHint(c));
|
|
31
|
+
else
|
|
32
|
+
query.noIndexHint(args.noIndexHint);
|
|
33
|
+
}
|
|
18
34
|
if (where)
|
|
19
35
|
query.where(where);
|
|
20
36
|
// Execute query
|
|
@@ -23,8 +23,12 @@ export class CreateCommand {
|
|
|
23
23
|
if (!ctx.colCount)
|
|
24
24
|
throw new Error('No field given to create new entity instance');
|
|
25
25
|
const query = Insert(tableName, ctx.queryValues);
|
|
26
|
-
if (args.comment)
|
|
27
|
-
|
|
26
|
+
if (args.comment) {
|
|
27
|
+
if (Array.isArray(args.comment))
|
|
28
|
+
args.comment.forEach(c => query.comment(c));
|
|
29
|
+
else
|
|
30
|
+
query.comment(args.comment);
|
|
31
|
+
}
|
|
28
32
|
if (args.returning) {
|
|
29
33
|
const primaryIndexColumns = EntityMetadata.getPrimaryIndexColumns(entity);
|
|
30
34
|
if (primaryIndexColumns.length)
|
|
@@ -13,8 +13,24 @@ export class DeleteCommand {
|
|
|
13
13
|
await prepareFilter(entity, filter, where);
|
|
14
14
|
}
|
|
15
15
|
const query = Delete(entity.tableName + ' T');
|
|
16
|
-
if (args.comment)
|
|
17
|
-
|
|
16
|
+
if (args.comment) {
|
|
17
|
+
if (Array.isArray(args.comment))
|
|
18
|
+
args.comment.forEach(c => query.comment(c));
|
|
19
|
+
else
|
|
20
|
+
query.comment(args.comment);
|
|
21
|
+
}
|
|
22
|
+
if (args.indexHint) {
|
|
23
|
+
if (Array.isArray(args.indexHint))
|
|
24
|
+
args.indexHint.forEach(c => query.indexHint(c));
|
|
25
|
+
else
|
|
26
|
+
query.indexHint(args.indexHint);
|
|
27
|
+
}
|
|
28
|
+
if (args.noIndexHint) {
|
|
29
|
+
if (Array.isArray(args.noIndexHint))
|
|
30
|
+
args.noIndexHint.forEach(c => query.noIndexHint(c));
|
|
31
|
+
else
|
|
32
|
+
query.noIndexHint(args.noIndexHint);
|
|
33
|
+
}
|
|
18
34
|
if (where)
|
|
19
35
|
query.where(...where._items);
|
|
20
36
|
// Execute query
|
|
@@ -38,6 +38,6 @@ export declare class FindCommand {
|
|
|
38
38
|
private _selectColumn;
|
|
39
39
|
filter(filter: any): Promise<void>;
|
|
40
40
|
sort(sortFields: string[]): Promise<void>;
|
|
41
|
-
execute(args: Pick<FindCommandArgs, 'connection' | 'distinct' | 'offset' | 'limit' | 'params' | 'onTransformRow' | 'prettyPrint' | 'comment' | '
|
|
41
|
+
execute(args: Pick<FindCommandArgs, 'connection' | 'distinct' | 'offset' | 'limit' | 'params' | 'onTransformRow' | 'prettyPrint' | 'comment' | 'indexHint' | 'noIndexHint'>): Promise<any[]>;
|
|
42
42
|
private _getEntityFromAlias;
|
|
43
43
|
}
|
|
@@ -242,8 +242,24 @@ export class FindCommand {
|
|
|
242
242
|
if (!columnSqls.length)
|
|
243
243
|
columnSqls.push('1');
|
|
244
244
|
const query = Select(...columnSqls).from(this.mainEntity.tableName + ' as ' + this.mainAlias);
|
|
245
|
-
if (args.comment)
|
|
246
|
-
|
|
245
|
+
if (args.comment) {
|
|
246
|
+
if (Array.isArray(args.comment))
|
|
247
|
+
args.comment.forEach(c => query.comment(c));
|
|
248
|
+
else
|
|
249
|
+
query.comment(args.comment);
|
|
250
|
+
}
|
|
251
|
+
if (args.indexHint) {
|
|
252
|
+
if (Array.isArray(args.indexHint))
|
|
253
|
+
args.indexHint.forEach(c => query.indexHint(c));
|
|
254
|
+
else
|
|
255
|
+
query.indexHint(args.indexHint);
|
|
256
|
+
}
|
|
257
|
+
if (args.noIndexHint) {
|
|
258
|
+
if (Array.isArray(args.noIndexHint))
|
|
259
|
+
args.noIndexHint.forEach(c => query.noIndexHint(c));
|
|
260
|
+
else
|
|
261
|
+
query.noIndexHint(args.noIndexHint);
|
|
262
|
+
}
|
|
247
263
|
if (args.distinct)
|
|
248
264
|
query.distinct();
|
|
249
265
|
query.where(...this._filter._items);
|
|
@@ -26,8 +26,24 @@ export class UpdateCommand {
|
|
|
26
26
|
if (args.filter)
|
|
27
27
|
await this._prepareFilter(ctx, args.filter);
|
|
28
28
|
const query = Update(tableName + ' as T', ctx.queryValues).where(...ctx.queryFilter);
|
|
29
|
-
if (args.comment)
|
|
30
|
-
|
|
29
|
+
if (args.comment) {
|
|
30
|
+
if (Array.isArray(args.comment))
|
|
31
|
+
args.comment.forEach(c => query.comment(c));
|
|
32
|
+
else
|
|
33
|
+
query.comment(args.comment);
|
|
34
|
+
}
|
|
35
|
+
if (args.indexHint) {
|
|
36
|
+
if (Array.isArray(args.indexHint))
|
|
37
|
+
args.indexHint.forEach(c => query.indexHint(c));
|
|
38
|
+
else
|
|
39
|
+
query.indexHint(args.indexHint);
|
|
40
|
+
}
|
|
41
|
+
if (args.noIndexHint) {
|
|
42
|
+
if (Array.isArray(args.noIndexHint))
|
|
43
|
+
args.noIndexHint.forEach(c => query.noIndexHint(c));
|
|
44
|
+
else
|
|
45
|
+
query.noIndexHint(args.noIndexHint);
|
|
46
|
+
}
|
|
31
47
|
const qr = await args.connection.execute(query, {
|
|
32
48
|
params: args.params ? [...args.params, ctx.queryParams] : ctx.queryParams,
|
|
33
49
|
objectRows: false,
|
|
@@ -17,8 +17,27 @@ export declare namespace Repository {
|
|
|
17
17
|
interface CommandOptions {
|
|
18
18
|
connection?: SqbConnection;
|
|
19
19
|
prettyPrint?: boolean;
|
|
20
|
-
comment?: string
|
|
21
|
-
|
|
20
|
+
comment?: string | string[] | {
|
|
21
|
+
comment: string;
|
|
22
|
+
dialect?: string[];
|
|
23
|
+
} | {
|
|
24
|
+
comment: string;
|
|
25
|
+
dialect?: string[];
|
|
26
|
+
}[];
|
|
27
|
+
indexHint?: string | string[] | {
|
|
28
|
+
index: string[];
|
|
29
|
+
dialect?: string[];
|
|
30
|
+
} | {
|
|
31
|
+
index: string[];
|
|
32
|
+
dialect?: string[];
|
|
33
|
+
}[];
|
|
34
|
+
noIndexHint?: string | string[] | {
|
|
35
|
+
index: string[];
|
|
36
|
+
dialect?: string[];
|
|
37
|
+
} | {
|
|
38
|
+
index: string[];
|
|
39
|
+
dialect?: string[];
|
|
40
|
+
}[];
|
|
22
41
|
}
|
|
23
42
|
interface CreateOptions extends CommandOptions, Projection {
|
|
24
43
|
}
|
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.25.0",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"dependencies": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"tslib": "^2.8.1"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
|
-
"@sqb/builder": "^4.
|
|
24
|
+
"@sqb/builder": "^4.25.0",
|
|
25
25
|
"reflect-metadata": "^0.2.2"
|
|
26
26
|
},
|
|
27
27
|
"type": "module",
|