typeorm-extensions 1.3.1 → 1.3.4
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/README.md +2 -2
- package/dist/extensions/get-many-with-totals.extension.d.ts +7 -1
- package/dist/extensions/get-many-with-totals.extension.js +2 -6
- package/dist/extensions/order.extension.d.ts +8 -1
- package/dist/extensions/order.extension.js +14 -10
- package/dist/extensions/pagination.extension.d.ts +8 -1
- package/dist/extensions/pagination.extension.js +0 -1
- package/dist/extensions/typed/typed-distinct/typed-distinct.extension.d.ts +14 -1
- package/dist/extensions/typed/typed-distinct/typed-distinct.extension.js +0 -1
- package/dist/extensions/typed/typed-joins/typed-joins.extension.d.ts +10 -1
- package/dist/extensions/typed/typed-joins/typed-joins.extension.js +1 -2
- package/dist/extensions/typed/typed-order-by/typed-order-by.extension.d.ts +17 -1
- package/dist/extensions/typed/typed-order-by/typed-order-by.extension.js +2 -3
- package/dist/extensions/typed/typed-select/typed-select.extension.d.ts +34 -1
- package/dist/extensions/typed/typed-select/typed-select.extension.js +12 -9
- package/dist/extensions/typed/typed-where/typed-where-is-in.extension.d.ts +132 -1
- package/dist/extensions/typed/typed-where/typed-where-is-in.extension.js +0 -1
- package/dist/extensions/typed/typed-where/typed-where.extension.d.ts +87 -1
- package/dist/extensions/typed/typed-where/typed-where.extension.js +0 -1
- package/dist/extensions/where-is-in.extension.d.ts +130 -1
- package/dist/extensions/where-is-in.extension.js +0 -1
- package/dist/types/interfaces/ordering.interface.d.ts +8 -3
- package/dist/utils/prototype.utils.js +1 -1
- package/dist/utils/proxy-key.utils.d.ts +2 -2
- package/dist/utils/proxy-key.utils.js +5 -5
- package/dist/utils/where.utils.js +8 -2
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -42,8 +42,8 @@ const query = myDataSource
|
|
|
42
42
|
name: user.name,
|
|
43
43
|
email: user.email,
|
|
44
44
|
]))
|
|
45
|
-
.whereTyped(user => user.name, 'ILIKE',
|
|
46
|
-
.andWhereTyped(user => user.metadata, ` ->> 'jsonField' =`,
|
|
45
|
+
.whereTyped(user => user.name, 'ILIKE', 'John')
|
|
46
|
+
.andWhereTyped(user => user.metadata, ` ->> 'jsonField' =`, 'some-value')
|
|
47
47
|
// Order by type-safe own and relation properties
|
|
48
48
|
.orderByTyped(user => user.images.url, 'ASC', 'NULLS LAST')
|
|
49
49
|
// Use pagination as simple as that
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
import './declarations/get-many-with-totals.declaration';
|
|
2
1
|
import './pagination.extension';
|
|
2
|
+
import { PaginationFilter } from '../types/interfaces/pagination.interface';
|
|
3
|
+
import type { GetManyWithTotalsOptions, ListWithTotals } from '../types/extensions';
|
|
4
|
+
declare module 'typeorm/query-builder/SelectQueryBuilder' {
|
|
5
|
+
interface SelectQueryBuilder<Entity> {
|
|
6
|
+
getManyWithTotals(paginationFilter: PaginationFilter, options?: GetManyWithTotalsOptions): Promise<ListWithTotals<Entity>>;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
require("./
|
|
3
|
+
require("./pagination.extension");
|
|
4
4
|
const SelectQueryBuilder_1 = require("typeorm/query-builder/SelectQueryBuilder");
|
|
5
5
|
const pagination_utils_1 = require("../utils/pagination.utils");
|
|
6
|
-
require("./pagination.extension");
|
|
7
6
|
const prototype_utils_1 = require("../utils/prototype.utils");
|
|
8
7
|
// patching
|
|
9
8
|
const extension = {
|
|
@@ -20,13 +19,10 @@ async function getManyWithTotals(builder, paginationFilter, options) {
|
|
|
20
19
|
const { limit, offset } = loadAll
|
|
21
20
|
? { limit: null, offset: null }
|
|
22
21
|
: (0, pagination_utils_1.getLimitAndOffset)(paginationFilter);
|
|
23
|
-
const requests = [];
|
|
22
|
+
const requests = [null, []];
|
|
24
23
|
if (!disableTotalsCalculation) {
|
|
25
24
|
requests[0] = await builder.getCount();
|
|
26
25
|
}
|
|
27
|
-
else {
|
|
28
|
-
requests[0] = null;
|
|
29
|
-
}
|
|
30
26
|
if (loadAll) {
|
|
31
27
|
requests[1] = await builder.getMany();
|
|
32
28
|
}
|
|
@@ -1 +1,8 @@
|
|
|
1
|
-
import '
|
|
1
|
+
import type { OrderParam, OrderFilter } from '../types/interfaces/ordering.interface';
|
|
2
|
+
import type { ApplyOrderOptions } from '../types/extensions/order.types';
|
|
3
|
+
declare module 'typeorm/query-builder/SelectQueryBuilder' {
|
|
4
|
+
interface SelectQueryBuilder<Entity> {
|
|
5
|
+
applyOrder<OrderEntity>(orderBy: OrderParam<OrderEntity>, options?: ApplyOrderOptions): SelectQueryBuilder<Entity>;
|
|
6
|
+
applyOrderFilter<OrderEntity>(orderFilter: OrderFilter<OrderEntity>, options?: ApplyOrderOptions): SelectQueryBuilder<Entity>;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
4
|
-
require("./declarations/order.declaration");
|
|
5
4
|
const SelectQueryBuilder_1 = require("typeorm/query-builder/SelectQueryBuilder");
|
|
6
5
|
const constants_1 = require("../constants");
|
|
7
6
|
const common_utils_1 = require("../utils/common.utils");
|
|
@@ -31,18 +30,23 @@ const alwaysAliasWhiteList = [
|
|
|
31
30
|
];
|
|
32
31
|
function getOrderOption(orderBy, defaultAlias, options) {
|
|
33
32
|
const { useDoubleQuotes = constants_1.defaultUseDoubleQuotes, alias: customAlias, alwaysAliasFields = alwaysAliasWhiteList, } = options !== null && options !== void 0 ? options : {};
|
|
34
|
-
const { field, direction
|
|
35
|
-
const alias =
|
|
33
|
+
const { field, direction, isReversed, nulls: nullsOrder, tableAlias: otherTableAlias, } = orderBy;
|
|
34
|
+
const alias = otherTableAlias || customAlias ||
|
|
35
|
+
(alwaysAliasFields.includes(field) ? defaultAlias : undefined);
|
|
36
36
|
const identifier = new identifier_utils_1.Identifier(field, alias, useDoubleQuotes);
|
|
37
37
|
const selector = identifier.fieldIdentifier();
|
|
38
|
-
const order = typeof
|
|
39
|
-
?
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
const order = typeof isReversed === 'boolean' && (0, common_utils_1.isNil)(direction)
|
|
39
|
+
? (isReversed ? 'DESC' : 'ASC')
|
|
40
|
+
: typeof direction === 'boolean'
|
|
41
|
+
? (direction ? 'ASC' : 'DESC')
|
|
42
|
+
: typeof direction === 'number'
|
|
43
|
+
? (direction === -1 ? 'DESC' : 'ASC')
|
|
44
|
+
: typeof direction === 'string' && /asc|desc/i.test(direction)
|
|
45
|
+
? direction.toUpperCase()
|
|
46
|
+
: constants_1.defaultOrderDirection;
|
|
47
|
+
const nulls = typeof nullsOrder === 'string' && /first|last/i.test(nullsOrder)
|
|
44
48
|
? `NULLS ${nullsOrder.toUpperCase()}`
|
|
45
|
-
:
|
|
49
|
+
: constants_1.defaultNullsOrder;
|
|
46
50
|
return {
|
|
47
51
|
selector,
|
|
48
52
|
order,
|
|
@@ -1 +1,8 @@
|
|
|
1
|
-
import '
|
|
1
|
+
import { PaginationFilter } from '../types/interfaces/pagination.interface';
|
|
2
|
+
import { ObjectLiteral } from 'typeorm';
|
|
3
|
+
import { ApplyPaginationOptions } from '../types/extensions/pagination.types';
|
|
4
|
+
declare module 'typeorm/query-builder/SelectQueryBuilder' {
|
|
5
|
+
interface SelectQueryBuilder<Entity extends ObjectLiteral> {
|
|
6
|
+
applyPaginationFilter(paginationFilter: PaginationFilter, options?: ApplyPaginationOptions): SelectQueryBuilder<Entity>;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
4
|
-
require("./declarations/pagination.declaration");
|
|
5
4
|
const SelectQueryBuilder_1 = require("typeorm/query-builder/SelectQueryBuilder");
|
|
6
5
|
const constants_1 = require("../constants");
|
|
7
6
|
const pagination_utils_1 = require("../utils/pagination.utils");
|
|
@@ -1 +1,14 @@
|
|
|
1
|
-
import '
|
|
1
|
+
import { ObjectLiteral } from 'typeorm';
|
|
2
|
+
import { KeyProxyCallback } from '../../../types/modules/proxy-callback.types';
|
|
3
|
+
declare module 'typeorm/query-builder/SelectQueryBuilder' {
|
|
4
|
+
interface SelectQueryBuilder<Entity extends ObjectLiteral> {
|
|
5
|
+
/**
|
|
6
|
+
* Sets the distinct on clause for Postgres.
|
|
7
|
+
*/
|
|
8
|
+
distinctOnTyped<Type extends ObjectLiteral = Entity>(this: SelectQueryBuilder<Entity>, ...distinctOn: Array<KeyProxyCallback<Type>>): SelectQueryBuilder<Entity>;
|
|
9
|
+
/**
|
|
10
|
+
* Sets the distinct on clause for Postgres.
|
|
11
|
+
*/
|
|
12
|
+
distinctOnTyped<Type extends ObjectLiteral = Entity>(this: SelectQueryBuilder<Entity>, distinctOn: KeyProxyCallback<Type>): SelectQueryBuilder<Entity>;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
require("../../declarations/typed/typed-distinct.declaration");
|
|
4
3
|
const typeorm_1 = require("typeorm");
|
|
5
4
|
const proxy_key_utils_1 = require("../../../utils/proxy-key.utils");
|
|
6
5
|
// patching and implementation
|
|
@@ -1 +1,10 @@
|
|
|
1
|
-
import '
|
|
1
|
+
import { ObjectLiteral } from 'typeorm';
|
|
2
|
+
import { RelationalKeyProxyCallback } from '../../../types/modules/proxy-callback.types';
|
|
3
|
+
declare module 'typeorm/query-builder/SelectQueryBuilder' {
|
|
4
|
+
interface SelectQueryBuilder<Entity extends ObjectLiteral> {
|
|
5
|
+
leftJoinTyped<Type extends ObjectLiteral = Entity>(this: SelectQueryBuilder<Entity>, selection: RelationalKeyProxyCallback<Type>, alias: string, condition?: string, parameters?: ObjectLiteral): SelectQueryBuilder<Entity>;
|
|
6
|
+
innerJoinTyped<Type extends ObjectLiteral = Entity>(this: SelectQueryBuilder<Entity>, selection: RelationalKeyProxyCallback<Type>, alias: string, condition?: string, parameters?: ObjectLiteral): SelectQueryBuilder<Entity>;
|
|
7
|
+
leftJoinAndSelectTyped<Type extends ObjectLiteral = Entity>(this: SelectQueryBuilder<Entity>, selection: RelationalKeyProxyCallback<Type>, alias: string, condition?: string, parameters?: ObjectLiteral): SelectQueryBuilder<Entity>;
|
|
8
|
+
innerJoinAndSelectTyped<Type extends ObjectLiteral = Entity>(this: SelectQueryBuilder<Entity>, selection: RelationalKeyProxyCallback<Type>, alias: string, condition?: string, parameters?: ObjectLiteral): SelectQueryBuilder<Entity>;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
require("../../declarations/typed/typed-joins.declaration");
|
|
4
3
|
const typeorm_1 = require("typeorm");
|
|
5
4
|
const proxy_key_utils_1 = require("../../../utils/proxy-key.utils");
|
|
6
5
|
// patching
|
|
@@ -29,6 +28,6 @@ typeorm_1.SelectQueryBuilder.prototype.innerJoinAndSelectTyped = function (selec
|
|
|
29
28
|
return this;
|
|
30
29
|
};
|
|
31
30
|
function addJoin(query, method, selection, alias, condition, parameters) {
|
|
32
|
-
const key = (0, proxy_key_utils_1.getSqlKeyFromProxyCallback)(selection, query.alias);
|
|
31
|
+
const key = (0, proxy_key_utils_1.getSqlKeyFromProxyCallback)(selection, query.alias, false);
|
|
33
32
|
return query[method](key, alias, condition, parameters);
|
|
34
33
|
}
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
import '
|
|
1
|
+
import { ObjectLiteral } from 'typeorm';
|
|
2
|
+
import { ProxyColumnValueType } from '../../../types/modules/proxy-callback.types';
|
|
3
|
+
import { KeyHolder } from '../../../utils/proxy-key.utils';
|
|
4
|
+
declare module 'typeorm/query-builder/SelectQueryBuilder' {
|
|
5
|
+
interface SelectQueryBuilder<Entity extends ObjectLiteral> {
|
|
6
|
+
/**
|
|
7
|
+
* Sets ORDER BY condition in the query builder.
|
|
8
|
+
* If you had previously ORDER BY expression defined,
|
|
9
|
+
* calling this function will override previously set ORDER BY conditions.
|
|
10
|
+
*/
|
|
11
|
+
orderByTyped<Type extends ObjectLiteral = Entity>(this: SelectQueryBuilder<Entity>, selection: (proxy: Type) => ProxyColumnValueType | KeyHolder, order?: 'ASC' | 'DESC', nulls?: 'NULLS FIRST' | 'NULLS LAST'): SelectQueryBuilder<Entity>;
|
|
12
|
+
/**
|
|
13
|
+
* Adds ORDER BY condition in the query builder.
|
|
14
|
+
*/
|
|
15
|
+
addOrderByTyped<Type extends ObjectLiteral = Entity>(this: SelectQueryBuilder<Entity>, selection: (proxy: Type) => ProxyColumnValueType | KeyHolder, order?: 'ASC' | 'DESC', nulls?: 'NULLS FIRST' | 'NULLS LAST'): SelectQueryBuilder<Entity>;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
require("../../declarations/typed/typed-order-by.declaration");
|
|
4
3
|
const typeorm_1 = require("typeorm");
|
|
5
4
|
const proxy_key_utils_1 = require("../../../utils/proxy-key.utils");
|
|
6
5
|
// patching and implementation
|
|
@@ -14,12 +13,12 @@ typeorm_1.SelectQueryBuilder.prototype.orderByTyped = function (selection, order
|
|
|
14
13
|
}
|
|
15
14
|
return this;
|
|
16
15
|
};
|
|
17
|
-
typeorm_1.SelectQueryBuilder.prototype.addOrderByTyped = function (selection, order, nulls) {
|
|
16
|
+
typeorm_1.SelectQueryBuilder.prototype.addOrderByTyped = function (selection, order, nulls, useDoubleQuotes) {
|
|
18
17
|
if (selection instanceof proxy_key_utils_1.KeyHolder) {
|
|
19
18
|
return this.addOrderBy(selection.toSql(), order, nulls);
|
|
20
19
|
}
|
|
21
20
|
if (typeof selection === 'function') {
|
|
22
|
-
const key = (0, proxy_key_utils_1.getSqlKeyFromProxyCallback)(selection, this.alias);
|
|
21
|
+
const key = (0, proxy_key_utils_1.getSqlKeyFromProxyCallback)(selection, this.alias, useDoubleQuotes);
|
|
23
22
|
return this.addOrderBy(key, order, nulls);
|
|
24
23
|
}
|
|
25
24
|
return this;
|
|
@@ -1 +1,34 @@
|
|
|
1
|
-
import '
|
|
1
|
+
import { ObjectLiteral } from 'typeorm';
|
|
2
|
+
import { KeyProxyCallback } from '../../../types/modules/proxy-callback.types';
|
|
3
|
+
import { KeyHolder } from '../../../utils/proxy-key.utils';
|
|
4
|
+
declare module 'typeorm/query-builder/SelectQueryBuilder' {
|
|
5
|
+
interface SelectQueryBuilder<Entity> {
|
|
6
|
+
/**
|
|
7
|
+
* Creates SELECT query.
|
|
8
|
+
* Replaces all previous selections if they exist.
|
|
9
|
+
*/
|
|
10
|
+
selectTyped<Type extends ObjectLiteral = Entity>(this: SelectQueryBuilder<Entity>, selection: KeyProxyCallback<Type>, selectionAliasName?: string, useDoubleQuotes?: boolean): SelectQueryBuilder<Entity>;
|
|
11
|
+
/**
|
|
12
|
+
* Creates SELECT query and selects given data.
|
|
13
|
+
* Replaces all previous selections if they exist.
|
|
14
|
+
*/
|
|
15
|
+
selectTyped(this: SelectQueryBuilder<Entity>, selection: string | KeyHolder, selectionAliasName?: string, useDoubleQuotes?: boolean): SelectQueryBuilder<Entity>;
|
|
16
|
+
/**
|
|
17
|
+
* Creates SELECT query and selects given data.
|
|
18
|
+
* Replaces all previous selections if they exist.
|
|
19
|
+
*/
|
|
20
|
+
selectTyped<Type extends ObjectLiteral = Entity>(this: SelectQueryBuilder<Entity>, selection: string[] | KeyHolder[] | Array<KeyProxyCallback<Type>>, useDoubleQuotes?: boolean): SelectQueryBuilder<Entity>;
|
|
21
|
+
/**
|
|
22
|
+
* Adds new selection to the SELECT query.
|
|
23
|
+
*/
|
|
24
|
+
addSelectTyped<Type extends ObjectLiteral = Entity>(this: SelectQueryBuilder<Entity>, selection: KeyProxyCallback<Type>, selectionAliasName?: string, useDoubleQuotes?: boolean): SelectQueryBuilder<Entity>;
|
|
25
|
+
/**
|
|
26
|
+
* Adds new selection to the SELECT query.
|
|
27
|
+
*/
|
|
28
|
+
addSelectTyped(this: SelectQueryBuilder<Entity>, selection: string | KeyHolder, selectionAliasName?: string, useDoubleQuotes?: boolean): SelectQueryBuilder<Entity>;
|
|
29
|
+
/**
|
|
30
|
+
* Adds new selection to the SELECT query.
|
|
31
|
+
*/
|
|
32
|
+
addSelectTyped<Type extends ObjectLiteral = Entity>(this: SelectQueryBuilder<Entity>, selection: string[] | KeyHolder[] | Array<KeyProxyCallback<Type>>, useDoubleQuotes?: boolean): SelectQueryBuilder<Entity>;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -1,32 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
require("../../declarations/typed/typed-select.declaration");
|
|
4
3
|
const typeorm_1 = require("typeorm");
|
|
5
4
|
const proxy_key_utils_1 = require("../../../utils/proxy-key.utils");
|
|
6
5
|
const prototype_utils_1 = require("../../../utils/prototype.utils");
|
|
7
6
|
// patching
|
|
8
7
|
const extension = {
|
|
9
8
|
prototype: {
|
|
10
|
-
selectTyped(selection, selectionAliasName) {
|
|
11
|
-
return attachSelectMethod(this, 'select', selection, selectionAliasName
|
|
9
|
+
selectTyped(selection, selectionAliasName, useDoubleQuotes) {
|
|
10
|
+
return attachSelectMethod(this, 'select', selection, typeof selectionAliasName === 'string' ? selectionAliasName : undefined, typeof selectionAliasName === 'boolean'
|
|
11
|
+
? selectionAliasName
|
|
12
|
+
: useDoubleQuotes);
|
|
12
13
|
},
|
|
13
|
-
addSelectTyped(selection, selectionAliasName) {
|
|
14
|
-
return attachSelectMethod(this, 'addSelect', selection, selectionAliasName
|
|
14
|
+
addSelectTyped(selection, selectionAliasName, useDoubleQuotes) {
|
|
15
|
+
return attachSelectMethod(this, 'addSelect', selection, typeof selectionAliasName === 'string' ? selectionAliasName : undefined, typeof selectionAliasName === 'boolean'
|
|
16
|
+
? selectionAliasName
|
|
17
|
+
: useDoubleQuotes);
|
|
15
18
|
},
|
|
16
19
|
},
|
|
17
20
|
};
|
|
18
21
|
(0, prototype_utils_1.patchPrototype)(typeorm_1.SelectQueryBuilder, extension);
|
|
19
22
|
// implementation
|
|
20
|
-
const attachSelectMethod = (query, method, selection, selectionAliasName) => {
|
|
23
|
+
const attachSelectMethod = (query, method, selection, selectionAliasName, useDoubleQuotes) => {
|
|
21
24
|
if (selection instanceof proxy_key_utils_1.KeyHolder) {
|
|
22
|
-
return query[method](selection.toSql(), selectionAliasName);
|
|
25
|
+
return query[method](selection.toSql(undefined, useDoubleQuotes), selectionAliasName);
|
|
23
26
|
}
|
|
24
27
|
if (Array.isArray(selection)) {
|
|
25
|
-
const arrayOfKeys = selection.map((select) => (0, proxy_key_utils_1.getSqlKeyFromProxyCallback)(select, query.alias));
|
|
28
|
+
const arrayOfKeys = selection.map((select) => (0, proxy_key_utils_1.getSqlKeyFromProxyCallback)(select, query.alias, useDoubleQuotes));
|
|
26
29
|
return query[method](arrayOfKeys);
|
|
27
30
|
}
|
|
28
31
|
else if (typeof selection === 'function') {
|
|
29
|
-
const keyArrayOrSingleKey = (0, proxy_key_utils_1.getSqlKeyFromProxyCallback)(selection, query.alias);
|
|
32
|
+
const keyArrayOrSingleKey = (0, proxy_key_utils_1.getSqlKeyFromProxyCallback)(selection, query.alias, useDoubleQuotes);
|
|
30
33
|
if (Array.isArray(keyArrayOrSingleKey)) {
|
|
31
34
|
return query[method](keyArrayOrSingleKey);
|
|
32
35
|
}
|
|
@@ -1,2 +1,133 @@
|
|
|
1
|
-
import '../../declarations/typed/typed-where-is-in.declaration';
|
|
2
1
|
import '../../where-is-in.extension';
|
|
2
|
+
import { ObjectLiteral } from 'typeorm';
|
|
3
|
+
import { ProxyColumnValueType } from '../../../types/modules/proxy-callback.types';
|
|
4
|
+
import { ArgsType } from '../../../types/util-types';
|
|
5
|
+
import { TypedWhereIsInOptions } from '../../../types/extensions/typed-where.types';
|
|
6
|
+
declare module 'typeorm/query-builder/WhereExpressionBuilder' {
|
|
7
|
+
interface WhereExpressionBuilder {
|
|
8
|
+
/**
|
|
9
|
+
* Sets WHERE IN condition in the query builder.
|
|
10
|
+
* If you had previously WHERE expression defined,
|
|
11
|
+
* calling this function will override previously set WHERE conditions.
|
|
12
|
+
*/
|
|
13
|
+
whereIsInTyped<Type extends ObjectLiteral>(subQuery: (proxy: Type) => ProxyColumnValueType, array?: ArgsType, options?: TypedWhereIsInOptions): this;
|
|
14
|
+
/**
|
|
15
|
+
* Adds new AND WHERE IN condition in the query builder.
|
|
16
|
+
*/
|
|
17
|
+
andWhereIsInTyped<Type extends ObjectLiteral>(subQuery: (proxy: Type) => ProxyColumnValueType, array?: ArgsType, options?: TypedWhereIsInOptions): this;
|
|
18
|
+
/**
|
|
19
|
+
* Adds new OR WHERE IN condition in the query builder.
|
|
20
|
+
*/
|
|
21
|
+
orWhereIsInTyped<Type extends ObjectLiteral>(subQuery: (proxy: Type) => ProxyColumnValueType, array?: ArgsType, options?: TypedWhereIsInOptions): this;
|
|
22
|
+
/**
|
|
23
|
+
* Sets WHERE NOT IN condition in the query builder.
|
|
24
|
+
* If you had previously WHERE expression defined,
|
|
25
|
+
* calling this function will override previously set WHERE conditions.
|
|
26
|
+
*/
|
|
27
|
+
whereIsNotInTyped<Type extends ObjectLiteral>(subQuery: (proxy: Type) => ProxyColumnValueType, array?: ArgsType, options?: TypedWhereIsInOptions): this;
|
|
28
|
+
/**
|
|
29
|
+
* Adds new AND WHERE NOT IN condition in the query builder.
|
|
30
|
+
*/
|
|
31
|
+
andWhereIsNotInTyped<Type extends ObjectLiteral>(subQuery: (proxy: Type) => ProxyColumnValueType, array?: ArgsType, options?: TypedWhereIsInOptions): this;
|
|
32
|
+
/**
|
|
33
|
+
* Adds new OR WHERE NOT IN condition in the query builder.
|
|
34
|
+
*/
|
|
35
|
+
orWhereIsNotInTyped<Type extends ObjectLiteral>(subQuery: (proxy: Type) => ProxyColumnValueType, array?: ArgsType, options?: TypedWhereIsInOptions): this;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
declare module 'typeorm/query-builder/SelectQueryBuilder' {
|
|
39
|
+
interface SelectQueryBuilder<Entity extends ObjectLiteral> {
|
|
40
|
+
/**
|
|
41
|
+
* Sets WHERE IN condition in the query builder.
|
|
42
|
+
* If you had previously WHERE expression defined,
|
|
43
|
+
* calling this function will override previously set WHERE conditions.
|
|
44
|
+
*/
|
|
45
|
+
whereIsInTyped<Type extends ObjectLiteral = Entity>(where: (proxy: Type) => ProxyColumnValueType, array?: ArgsType, options?: TypedWhereIsInOptions): this;
|
|
46
|
+
/**
|
|
47
|
+
* Adds new AND WHERE IN condition in the query builder.
|
|
48
|
+
*/
|
|
49
|
+
andWhereIsInTyped<Type extends ObjectLiteral = Entity>(where: (proxy: Type) => ProxyColumnValueType, array?: ArgsType, options?: TypedWhereIsInOptions): this;
|
|
50
|
+
/**
|
|
51
|
+
* Adds new OR WHERE IN condition in the query builder.
|
|
52
|
+
*/
|
|
53
|
+
orWhereIsInTyped<Type extends ObjectLiteral = Entity>(where: (proxy: Type) => ProxyColumnValueType, array?: ArgsType, options?: TypedWhereIsInOptions): this;
|
|
54
|
+
/**
|
|
55
|
+
* Sets WHERE NOT IN condition in the query builder.
|
|
56
|
+
* If you had previously WHERE expression defined,
|
|
57
|
+
* calling this function will override previously set WHERE conditions.
|
|
58
|
+
*/
|
|
59
|
+
whereIsNotInTyped<Type extends ObjectLiteral>(subQuery: (proxy: Type) => ProxyColumnValueType, array?: ArgsType, options?: TypedWhereIsInOptions): this;
|
|
60
|
+
/**
|
|
61
|
+
* Adds new AND WHERE NOT IN condition in the query builder.
|
|
62
|
+
*/
|
|
63
|
+
andWhereIsNotInTyped<Type extends ObjectLiteral>(subQuery: (proxy: Type) => ProxyColumnValueType, array?: ArgsType, options?: TypedWhereIsInOptions): this;
|
|
64
|
+
/**
|
|
65
|
+
* Adds new OR WHERE NOT IN condition in the query builder.
|
|
66
|
+
*/
|
|
67
|
+
orWhereIsNotInTyped<Type extends ObjectLiteral>(subQuery: (proxy: Type) => ProxyColumnValueType, array?: ArgsType, options?: TypedWhereIsInOptions): this;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
declare module 'typeorm/query-builder/UpdateQueryBuilder' {
|
|
71
|
+
interface UpdateQueryBuilder<Entity extends ObjectLiteral> {
|
|
72
|
+
/**
|
|
73
|
+
* Sets WHERE IN condition in the query builder.
|
|
74
|
+
* If you had previously WHERE expression defined,
|
|
75
|
+
* calling this function will override previously set WHERE conditions.
|
|
76
|
+
*/
|
|
77
|
+
whereIsInTyped<Type extends ObjectLiteral = Entity>(where: (proxy: Type) => ProxyColumnValueType, array?: ArgsType, options?: TypedWhereIsInOptions): this;
|
|
78
|
+
/**
|
|
79
|
+
* Adds new AND WHERE IN condition in the query builder.
|
|
80
|
+
*/
|
|
81
|
+
andWhereIsInTyped<Type extends ObjectLiteral = Entity>(where: (proxy: Type) => ProxyColumnValueType, array?: ArgsType, options?: TypedWhereIsInOptions): this;
|
|
82
|
+
/**
|
|
83
|
+
* Adds new OR WHERE IN condition in the query builder.
|
|
84
|
+
*/
|
|
85
|
+
orWhereIsInTyped<Type extends ObjectLiteral = Entity>(where: (proxy: Type) => ProxyColumnValueType, array?: ArgsType, options?: TypedWhereIsInOptions): this;
|
|
86
|
+
/**
|
|
87
|
+
* Sets WHERE NOT IN condition in the query builder.
|
|
88
|
+
* If you had previously WHERE expression defined,
|
|
89
|
+
* calling this function will override previously set WHERE conditions.
|
|
90
|
+
*/
|
|
91
|
+
whereIsNotInTyped<Type extends ObjectLiteral>(subQuery: (proxy: Type) => ProxyColumnValueType, array?: ArgsType, options?: TypedWhereIsInOptions): this;
|
|
92
|
+
/**
|
|
93
|
+
* Adds new AND WHERE NOT IN condition in the query builder.
|
|
94
|
+
*/
|
|
95
|
+
andWhereIsNotInTyped<Type extends ObjectLiteral>(subQuery: (proxy: Type) => ProxyColumnValueType, array?: ArgsType, options?: TypedWhereIsInOptions): this;
|
|
96
|
+
/**
|
|
97
|
+
* Adds new OR WHERE NOT IN condition in the query builder.
|
|
98
|
+
*/
|
|
99
|
+
orWhereIsNotInTyped<Type extends ObjectLiteral>(subQuery: (proxy: Type) => ProxyColumnValueType, array?: ArgsType, options?: TypedWhereIsInOptions): this;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
declare module 'typeorm/query-builder/DeleteQueryBuilder' {
|
|
103
|
+
interface DeleteQueryBuilder<Entity extends ObjectLiteral> {
|
|
104
|
+
/**
|
|
105
|
+
* Sets WHERE IN condition in the query builder.
|
|
106
|
+
* If you had previously WHERE expression defined,
|
|
107
|
+
* calling this function will override previously set WHERE conditions.
|
|
108
|
+
*/
|
|
109
|
+
whereIsInTyped<Type extends ObjectLiteral = Entity>(where: (proxy: Type) => ProxyColumnValueType, array?: ArgsType, options?: TypedWhereIsInOptions): this;
|
|
110
|
+
/**
|
|
111
|
+
* Adds new AND WHERE IN condition in the query builder.
|
|
112
|
+
*/
|
|
113
|
+
andWhereIsInTyped<Type extends ObjectLiteral = Entity>(where: (proxy: Type) => ProxyColumnValueType, array?: ArgsType, options?: TypedWhereIsInOptions): this;
|
|
114
|
+
/**
|
|
115
|
+
* Adds new OR WHERE IN condition in the query builder.
|
|
116
|
+
*/
|
|
117
|
+
orWhereIsInTyped<Type extends ObjectLiteral = Entity>(where: (proxy: Type) => ProxyColumnValueType, array?: ArgsType, options?: TypedWhereIsInOptions): this;
|
|
118
|
+
/**
|
|
119
|
+
* Sets WHERE NOT IN condition in the query builder.
|
|
120
|
+
* If you had previously WHERE expression defined,
|
|
121
|
+
* calling this function will override previously set WHERE conditions.
|
|
122
|
+
*/
|
|
123
|
+
whereIsNotInTyped<Type extends ObjectLiteral>(subQuery: (proxy: Type) => ProxyColumnValueType, array?: ArgsType, options?: TypedWhereIsInOptions): this;
|
|
124
|
+
/**
|
|
125
|
+
* Adds new AND WHERE NOT IN condition in the query builder.
|
|
126
|
+
*/
|
|
127
|
+
andWhereIsNotInTyped<Type extends ObjectLiteral>(subQuery: (proxy: Type) => ProxyColumnValueType, array?: ArgsType, options?: TypedWhereIsInOptions): this;
|
|
128
|
+
/**
|
|
129
|
+
* Adds new OR WHERE NOT IN condition in the query builder.
|
|
130
|
+
*/
|
|
131
|
+
orWhereIsNotInTyped<Type extends ObjectLiteral>(subQuery: (proxy: Type) => ProxyColumnValueType, array?: ArgsType, options?: TypedWhereIsInOptions): this;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
require("../../declarations/typed/typed-where-is-in.declaration");
|
|
4
3
|
require("../../where-is-in.extension");
|
|
5
4
|
const typeorm_1 = require("typeorm");
|
|
6
5
|
const proxy_key_utils_1 = require("../../../utils/proxy-key.utils");
|
|
@@ -1 +1,87 @@
|
|
|
1
|
-
import '
|
|
1
|
+
import { ObjectLiteral } from 'typeorm';
|
|
2
|
+
import { ProxyColumnValueType } from '../../../types/modules/proxy-callback.types';
|
|
3
|
+
import { TypedWhereOptions } from '../../../types/extensions/typed-where.types';
|
|
4
|
+
declare module 'typeorm/query-builder/WhereExpressionBuilder' {
|
|
5
|
+
interface WhereExpressionBuilder {
|
|
6
|
+
/**
|
|
7
|
+
* Sets WHERE condition in the query builder.
|
|
8
|
+
* If you had previously WHERE expression defined,
|
|
9
|
+
* calling this function will override previously set WHERE conditions.
|
|
10
|
+
* Additionally you can add parameters used in where expression.
|
|
11
|
+
*/
|
|
12
|
+
whereTyped<Type extends ObjectLiteral>(subQuery: (proxy: Type) => ProxyColumnValueType, conditions: string, parameters?: unknown, options?: TypedWhereOptions): this;
|
|
13
|
+
/**
|
|
14
|
+
* Adds new AND WHERE condition in the query builder.
|
|
15
|
+
* Additionally you can add parameters used in where expression.
|
|
16
|
+
*/
|
|
17
|
+
andWhereTyped<Type extends ObjectLiteral>(subQuery: (proxy: Type) => ProxyColumnValueType, conditions: string, parameters?: unknown, options?: TypedWhereOptions): this;
|
|
18
|
+
/**
|
|
19
|
+
* Adds new OR WHERE condition in the query builder.
|
|
20
|
+
* Additionally you can add parameters used in where expression.
|
|
21
|
+
*/
|
|
22
|
+
orWhereTyped<Type extends ObjectLiteral>(subQuery: (proxy: Type) => ProxyColumnValueType, conditions: string, parameters?: unknown, options?: TypedWhereOptions): this;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
declare module 'typeorm/query-builder/SelectQueryBuilder' {
|
|
26
|
+
interface SelectQueryBuilder<Entity> {
|
|
27
|
+
/**
|
|
28
|
+
* Sets WHERE condition in the query builder.
|
|
29
|
+
* If you had previously WHERE expression defined,
|
|
30
|
+
* calling this function will override previously set WHERE conditions.
|
|
31
|
+
* Additionally you can add parameters used in where expression.
|
|
32
|
+
*/
|
|
33
|
+
whereTyped<Type extends ObjectLiteral = Entity>(where: (proxy: Type) => ProxyColumnValueType, conditions: string, parameters?: unknown, options?: TypedWhereOptions): this;
|
|
34
|
+
/**
|
|
35
|
+
* Adds new AND WHERE condition in the query builder.
|
|
36
|
+
* Additionally you can add parameters used in where expression.
|
|
37
|
+
*/
|
|
38
|
+
andWhereTyped<Type extends ObjectLiteral = Entity>(where: (proxy: Type) => ProxyColumnValueType, conditions: string, parameters?: unknown, options?: TypedWhereOptions): this;
|
|
39
|
+
/**
|
|
40
|
+
* Adds new OR WHERE condition in the query builder.
|
|
41
|
+
* Additionally you can add parameters used in where expression.
|
|
42
|
+
*/
|
|
43
|
+
orWhereTyped<Type extends ObjectLiteral = Entity>(where: (proxy: Type) => ProxyColumnValueType, conditions: string, parameters?: unknown, options?: TypedWhereOptions): this;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
declare module 'typeorm/query-builder/UpdateQueryBuilder' {
|
|
47
|
+
interface UpdateQueryBuilder<Entity> {
|
|
48
|
+
/**
|
|
49
|
+
* Sets WHERE condition in the query builder.
|
|
50
|
+
* If you had previously WHERE expression defined,
|
|
51
|
+
* calling this function will override previously set WHERE conditions.
|
|
52
|
+
* Additionally you can add parameters used in where expression.
|
|
53
|
+
*/
|
|
54
|
+
whereTyped<Type extends ObjectLiteral = Entity>(where: (proxy: Type) => ProxyColumnValueType, conditions: string, parameters?: unknown, options?: TypedWhereOptions): this;
|
|
55
|
+
/**
|
|
56
|
+
* Adds new AND WHERE condition in the query builder.
|
|
57
|
+
* Additionally you can add parameters used in where expression.
|
|
58
|
+
*/
|
|
59
|
+
andWhereTyped<Type extends ObjectLiteral = Entity>(where: (proxy: Type) => ProxyColumnValueType, conditions: string, parameters?: unknown, options?: TypedWhereOptions): this;
|
|
60
|
+
/**
|
|
61
|
+
* Adds new OR WHERE condition in the query builder.
|
|
62
|
+
* Additionally you can add parameters used in where expression.
|
|
63
|
+
*/
|
|
64
|
+
orWhereTyped<Type extends ObjectLiteral = Entity>(where: (proxy: Type) => ProxyColumnValueType, conditions: string, parameters?: unknown, options?: TypedWhereOptions): this;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
declare module 'typeorm/query-builder/DeleteQueryBuilder' {
|
|
68
|
+
interface DeleteQueryBuilder<Entity> {
|
|
69
|
+
/**
|
|
70
|
+
* Sets WHERE condition in the query builder.
|
|
71
|
+
* If you had previously WHERE expression defined,
|
|
72
|
+
* calling this function will override previously set WHERE conditions.
|
|
73
|
+
* Additionally you can add parameters used in where expression.
|
|
74
|
+
*/
|
|
75
|
+
whereTyped<Type extends ObjectLiteral = Entity>(where: (proxy: Type) => ProxyColumnValueType, conditions: string, parameters?: unknown, options?: TypedWhereOptions): this;
|
|
76
|
+
/**
|
|
77
|
+
* Adds new AND WHERE condition in the query builder.
|
|
78
|
+
* Additionally you can add parameters used in where expression.
|
|
79
|
+
*/
|
|
80
|
+
andWhereTyped<Type extends ObjectLiteral = Entity>(where: (proxy: Type) => ProxyColumnValueType, conditions: string, parameters?: unknown, options?: TypedWhereOptions): this;
|
|
81
|
+
/**
|
|
82
|
+
* Adds new OR WHERE condition in the query builder.
|
|
83
|
+
* Additionally you can add parameters used in where expression.
|
|
84
|
+
*/
|
|
85
|
+
orWhereTyped<Type extends ObjectLiteral = Entity>(where: (proxy: Type) => ProxyColumnValueType, conditions: string, parameters?: unknown, options?: TypedWhereOptions): this;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
require("../../declarations/typed/typed-where.declaration");
|
|
4
3
|
const typeorm_1 = require("typeorm");
|
|
5
4
|
const proxy_key_utils_1 = require("../../../utils/proxy-key.utils");
|
|
6
5
|
const prototype_utils_1 = require("../../../utils/prototype.utils");
|
|
@@ -1 +1,130 @@
|
|
|
1
|
-
import '
|
|
1
|
+
import { ObjectLiteral } from 'typeorm';
|
|
2
|
+
import { ArgsType } from '../types/util-types';
|
|
3
|
+
declare module 'typeorm/query-builder/WhereExpressionBuilder' {
|
|
4
|
+
interface WhereExpressionBuilder {
|
|
5
|
+
/**
|
|
6
|
+
* Sets WHERE IN condition in the query builder.
|
|
7
|
+
* If you had previously WHERE expression defined,
|
|
8
|
+
* calling this function will override previously set WHERE conditions.
|
|
9
|
+
*/
|
|
10
|
+
whereIsIn(field: string, array?: ArgsType): this;
|
|
11
|
+
/**
|
|
12
|
+
* Adds new AND WHERE IN condition in the query builder.
|
|
13
|
+
*/
|
|
14
|
+
andWhereIsIn(field: string, array?: ArgsType): this;
|
|
15
|
+
/**
|
|
16
|
+
* Adds new OR WHERE IN condition in the query builder.
|
|
17
|
+
*/
|
|
18
|
+
orWhereIsIn(field: string, array?: ArgsType): this;
|
|
19
|
+
/**
|
|
20
|
+
* Sets WHERE NOT IN condition in the query builder.
|
|
21
|
+
* If you had previously WHERE expression defined,
|
|
22
|
+
* calling this function will override previously set WHERE conditions.
|
|
23
|
+
*/
|
|
24
|
+
whereIsNotIn(field: string, array?: ArgsType): this;
|
|
25
|
+
/**
|
|
26
|
+
* Adds new AND WHERE NOT IN condition in the query builder.
|
|
27
|
+
*/
|
|
28
|
+
andWhereIsNotIn(field: string, array?: ArgsType): this;
|
|
29
|
+
/**
|
|
30
|
+
* Adds new OR WHERE NOT IN condition in the query builder.
|
|
31
|
+
*/
|
|
32
|
+
orWhereIsNotIn(field: string, array?: ArgsType): this;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
declare module 'typeorm/query-builder/SelectQueryBuilder' {
|
|
36
|
+
interface SelectQueryBuilder<Entity extends ObjectLiteral> {
|
|
37
|
+
/**
|
|
38
|
+
* Sets WHERE IN condition in the query builder.
|
|
39
|
+
* If you had previously WHERE expression defined,
|
|
40
|
+
* calling this function will override previously set WHERE conditions.
|
|
41
|
+
*/
|
|
42
|
+
whereIsIn(field: string, array?: ArgsType): SelectQueryBuilder<Entity>;
|
|
43
|
+
/**
|
|
44
|
+
* Adds new AND WHERE IN condition in the query builder.
|
|
45
|
+
*/
|
|
46
|
+
andWhereIsIn(field: string, array?: ArgsType): SelectQueryBuilder<Entity>;
|
|
47
|
+
/**
|
|
48
|
+
* Adds new OR WHERE IN condition in the query builder.
|
|
49
|
+
*/
|
|
50
|
+
orWhereIsIn(field: string, array?: ArgsType): SelectQueryBuilder<Entity>;
|
|
51
|
+
/**
|
|
52
|
+
* Sets WHERE NOT IN condition in the query builder.
|
|
53
|
+
* If you had previously WHERE expression defined,
|
|
54
|
+
* calling this function will override previously set WHERE conditions.
|
|
55
|
+
*/
|
|
56
|
+
whereIsNotIn(field: string, array?: ArgsType): SelectQueryBuilder<Entity>;
|
|
57
|
+
/**
|
|
58
|
+
* Adds new AND WHERE NOT IN condition in the query builder.
|
|
59
|
+
*/
|
|
60
|
+
andWhereIsNotIn(field: string, array?: ArgsType): SelectQueryBuilder<Entity>;
|
|
61
|
+
/**
|
|
62
|
+
* Adds new OR WHERE NOT IN condition in the query builder.
|
|
63
|
+
*/
|
|
64
|
+
orWhereIsNotIn(field: string, array?: ArgsType): SelectQueryBuilder<Entity>;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
declare module 'typeorm/query-builder/UpdateQueryBuilder' {
|
|
68
|
+
interface UpdateQueryBuilder<Entity extends ObjectLiteral> {
|
|
69
|
+
/**
|
|
70
|
+
* Sets WHERE IN condition in the query builder.
|
|
71
|
+
* If you had previously WHERE expression defined,
|
|
72
|
+
* calling this function will override previously set WHERE conditions.
|
|
73
|
+
*/
|
|
74
|
+
whereIsIn(field: string, array?: ArgsType): UpdateQueryBuilder<Entity>;
|
|
75
|
+
/**
|
|
76
|
+
* Adds new AND WHERE IN condition in the query builder.
|
|
77
|
+
*/
|
|
78
|
+
andWhereIsIn(field: string, array?: ArgsType): UpdateQueryBuilder<Entity>;
|
|
79
|
+
/**
|
|
80
|
+
* Adds new OR WHERE IN condition in the query builder.
|
|
81
|
+
*/
|
|
82
|
+
orWhereIsIn(field: string, array?: ArgsType): UpdateQueryBuilder<Entity>;
|
|
83
|
+
/**
|
|
84
|
+
* Sets WHERE NOT IN condition in the query builder.
|
|
85
|
+
* If you had previously WHERE expression defined,
|
|
86
|
+
* calling this function will override previously set WHERE conditions.
|
|
87
|
+
*/
|
|
88
|
+
whereIsNotIn(field: string, array?: ArgsType): UpdateQueryBuilder<Entity>;
|
|
89
|
+
/**
|
|
90
|
+
* Adds new AND WHERE NOT IN condition in the query builder.
|
|
91
|
+
*/
|
|
92
|
+
andWhereIsNotIn(field: string, array?: ArgsType): UpdateQueryBuilder<Entity>;
|
|
93
|
+
/**
|
|
94
|
+
* Adds new OR WHERE NOT IN condition in the query builder.
|
|
95
|
+
*/
|
|
96
|
+
orWhereIsNotIn(field: string, array?: ArgsType): UpdateQueryBuilder<Entity>;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
declare module 'typeorm/query-builder/DeleteQueryBuilder' {
|
|
100
|
+
interface DeleteQueryBuilder<Entity extends ObjectLiteral> {
|
|
101
|
+
/**
|
|
102
|
+
* Sets WHERE IN condition in the query builder.
|
|
103
|
+
* If you had previously WHERE expression defined,
|
|
104
|
+
* calling this function will override previously set WHERE conditions.
|
|
105
|
+
*/
|
|
106
|
+
whereIsIn(field: string, array?: ArgsType): DeleteQueryBuilder<Entity>;
|
|
107
|
+
/**
|
|
108
|
+
* Adds new AND WHERE IN condition in the query builder.
|
|
109
|
+
*/
|
|
110
|
+
andWhereIsIn(field: string, array?: ArgsType): DeleteQueryBuilder<Entity>;
|
|
111
|
+
/**
|
|
112
|
+
* Adds new OR WHERE IN condition in the query builder.
|
|
113
|
+
*/
|
|
114
|
+
orWhereIsIn(field: string, array?: ArgsType): DeleteQueryBuilder<Entity>;
|
|
115
|
+
/**
|
|
116
|
+
* Sets WHERE NOT IN condition in the query builder.
|
|
117
|
+
* If you had previously WHERE expression defined,
|
|
118
|
+
* calling this function will override previously set WHERE conditions.
|
|
119
|
+
*/
|
|
120
|
+
whereIsNotIn(field: string, array?: ArgsType): DeleteQueryBuilder<Entity>;
|
|
121
|
+
/**
|
|
122
|
+
* Adds new AND WHERE NOT IN condition in the query builder.
|
|
123
|
+
*/
|
|
124
|
+
andWhereIsNotIn(field: string, array?: ArgsType): DeleteQueryBuilder<Entity>;
|
|
125
|
+
/**
|
|
126
|
+
* Adds new OR WHERE NOT IN condition in the query builder.
|
|
127
|
+
*/
|
|
128
|
+
orWhereIsNotIn(field: string, array?: ArgsType): DeleteQueryBuilder<Entity>;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
require("./declarations/where-is-in.daclaration");
|
|
4
3
|
const typeorm_1 = require("typeorm");
|
|
5
4
|
const prototype_utils_1 = require("../utils/prototype.utils");
|
|
6
5
|
const where_utils_1 = require("../utils/where.utils");
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { NonFunctionPropertyNames } from "../util-types";
|
|
2
|
-
export type OrderDirection = 'asc' | 'desc' | 'ASC' | 'DESC' | 1 | -1;
|
|
2
|
+
export type OrderDirection = 'asc' | 'desc' | 'ASC' | 'DESC' | 1 | -1 | true | false;
|
|
3
3
|
export type NullsOrder = 'first' | 'last' | 'FIRST' | 'LAST';
|
|
4
4
|
export type OrderParam<Entity> = {
|
|
5
|
-
field: NonFunctionPropertyNames<Required<Entity
|
|
5
|
+
field: NonFunctionPropertyNames<Required<Entity>>;
|
|
6
|
+
/** -1 = DESC, false = DESC */
|
|
6
7
|
direction?: OrderDirection;
|
|
7
8
|
nulls?: NullsOrder;
|
|
9
|
+
/** true = DESC, false = ASC */
|
|
10
|
+
isReversed?: boolean;
|
|
11
|
+
/** order by related table */
|
|
12
|
+
tableAlias?: string;
|
|
8
13
|
};
|
|
9
14
|
export type OrderType = {
|
|
10
15
|
selector: string;
|
|
11
|
-
order
|
|
16
|
+
order?: 'ASC' | 'DESC';
|
|
12
17
|
nulls?: 'NULLS FIRST' | 'NULLS LAST';
|
|
13
18
|
};
|
|
14
19
|
export interface OrderFilter<Entity> {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.patchPrototype = void 0;
|
|
5
5
|
function patchPrototype(target, source) {
|
|
6
|
-
for (const method
|
|
6
|
+
for (const method of Object.keys(source.prototype)) {
|
|
7
7
|
target.prototype[method] = source.prototype[method];
|
|
8
8
|
}
|
|
9
9
|
}
|
|
@@ -3,7 +3,7 @@ import { KeyProxyCallback } from '../types/modules/proxy-callback.types';
|
|
|
3
3
|
export declare class KeyHolder {
|
|
4
4
|
private _keys;
|
|
5
5
|
constructor(_keys?: string[]);
|
|
6
|
-
toSql(length?: number,
|
|
6
|
+
toSql(length?: number, useDoubleQuotes?: boolean): string;
|
|
7
7
|
toString(length?: number): string;
|
|
8
8
|
valueOf(): string;
|
|
9
9
|
[Symbol.toPrimitive](): string;
|
|
@@ -21,4 +21,4 @@ export declare class KeyProxy {
|
|
|
21
21
|
}
|
|
22
22
|
export declare const getKeyHolder: <Type extends ObjectLiteral>(callback: KeyHolder | KeyProxyCallback<Type>) => KeyHolder | Array<KeyHolder>;
|
|
23
23
|
export declare const getKey: <Type extends ObjectLiteral>(callback: string | KeyHolder | KeyProxyCallback<Type>) => string;
|
|
24
|
-
export declare const getSqlKeyFromProxyCallback: <Type extends ObjectLiteral>(callback: string | KeyHolder | KeyProxyCallback<Type>, addPrefix?: string,
|
|
24
|
+
export declare const getSqlKeyFromProxyCallback: <Type extends ObjectLiteral>(callback: string | KeyHolder | KeyProxyCallback<Type>, addPrefix?: string, useDoubleQuotes?: boolean) => string | string[];
|
|
@@ -7,9 +7,9 @@ class KeyHolder {
|
|
|
7
7
|
this._keys = _keys;
|
|
8
8
|
this._keys = [..._keys];
|
|
9
9
|
}
|
|
10
|
-
toSql(length = 2,
|
|
10
|
+
toSql(length = 2, useDoubleQuotes) {
|
|
11
11
|
const string = this.toString(length);
|
|
12
|
-
const sql =
|
|
12
|
+
const sql = useDoubleQuotes ? (0, sql_utils_1.stringToSQLIdentifier)(string) : string;
|
|
13
13
|
return sql;
|
|
14
14
|
}
|
|
15
15
|
toString(length = 2) {
|
|
@@ -86,7 +86,7 @@ const getKey = (callback) => {
|
|
|
86
86
|
return keyHolder.toString();
|
|
87
87
|
};
|
|
88
88
|
exports.getKey = getKey;
|
|
89
|
-
const getSqlKeyFromProxyCallback = (callback, addPrefix,
|
|
89
|
+
const getSqlKeyFromProxyCallback = (callback, addPrefix, useDoubleQuotes) => {
|
|
90
90
|
if (typeof callback === 'string')
|
|
91
91
|
return callback;
|
|
92
92
|
const keyHolder = (0, exports.getKeyHolder)(callback);
|
|
@@ -96,14 +96,14 @@ const getSqlKeyFromProxyCallback = (callback, addPrefix, addDobleQuotes = true)
|
|
|
96
96
|
// if select is like this: (proxy) => proxy.relation.column
|
|
97
97
|
if (keyHolder.getKeys().length > 1) {
|
|
98
98
|
// return unchanged
|
|
99
|
-
return keyHolder.toSql(undefined,
|
|
99
|
+
return keyHolder.toSql(undefined, useDoubleQuotes);
|
|
100
100
|
}
|
|
101
101
|
// else if select is one layer depth like this: (proxy) => proxy.column
|
|
102
102
|
// then add alias before the key
|
|
103
103
|
if (typeof addPrefix === 'string' && addPrefix.length >= 1) {
|
|
104
104
|
keyHolder.unshift(addPrefix);
|
|
105
105
|
}
|
|
106
|
-
return keyHolder.toSql(undefined,
|
|
106
|
+
return keyHolder.toSql(undefined, useDoubleQuotes);
|
|
107
107
|
};
|
|
108
108
|
exports.getSqlKeyFromProxyCallback = getSqlKeyFromProxyCallback;
|
|
109
109
|
// example of typed select
|
|
@@ -17,8 +17,14 @@ function attachWhere(builder, method, field, conditions, value, options) {
|
|
|
17
17
|
if (method && typeof field === 'string' && typeof conditions === 'string') {
|
|
18
18
|
field = (0, sql_utils_1.stringToSQLIdentifier)(field);
|
|
19
19
|
if (addValue) {
|
|
20
|
-
|
|
21
|
-
const
|
|
20
|
+
// is object (not primitive, null or array)
|
|
21
|
+
const firstValue = value !== null && typeof value === 'object' && !Array.isArray(value)
|
|
22
|
+
? Object.values(value)[0]
|
|
23
|
+
: value;
|
|
24
|
+
// 0, false, '' are valid values like any other
|
|
25
|
+
// null is a valid value, but undefined and NaN are not
|
|
26
|
+
const valueIsValid = firstValue !== undefined &&
|
|
27
|
+
(typeof firstValue === 'number' ? !isNaN(firstValue) : true);
|
|
22
28
|
const paramName = valueIsValid
|
|
23
29
|
? (0, sql_utils_1.createUniqueParameterName)(method)
|
|
24
30
|
: undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typeorm-extensions",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.4",
|
|
4
4
|
"description": "typeorm commonly used extensions",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -13,8 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"scripts": {
|
|
15
15
|
"build": "tsc -p .",
|
|
16
|
-
"lint": "eslint . --ext .ts"
|
|
17
|
-
"test-nest-build": "cd test/nest_v11 && npm install && npm run build"
|
|
16
|
+
"lint": "eslint . --ext .ts"
|
|
18
17
|
},
|
|
19
18
|
"keywords": [
|
|
20
19
|
"typeorm",
|
|
@@ -25,13 +24,14 @@
|
|
|
25
24
|
],
|
|
26
25
|
"author": "koenigstag",
|
|
27
26
|
"license": "ISC",
|
|
28
|
-
"
|
|
29
|
-
"typeorm": "^0.3.
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"typeorm": "^0.3.12"
|
|
30
29
|
},
|
|
31
30
|
"devDependencies": {
|
|
32
31
|
"@typescript-eslint/eslint-plugin": "^7.1.1",
|
|
33
32
|
"@typescript-eslint/parser": "^7.1.1",
|
|
34
33
|
"eslint": "^8.57.0",
|
|
34
|
+
"typeorm": "^0.3.12",
|
|
35
35
|
"typescript": "5.3"
|
|
36
36
|
}
|
|
37
37
|
}
|