@rafikidota/iroh 0.22.0 → 0.23.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/dist/common/database/data-source.provider.js.map +1 -0
- package/dist/common/database/index.d.ts +3 -0
- package/dist/common/database/index.js +3 -0
- package/dist/common/database/index.js.map +1 -1
- package/dist/common/database/query-builder/constant/index.d.ts +1 -0
- package/dist/common/database/query-builder/constant/index.js +18 -0
- package/dist/common/database/query-builder/constant/index.js.map +1 -0
- package/dist/common/database/query-builder/constant/sql-keys.d.ts +20 -0
- package/dist/common/database/query-builder/constant/sql-keys.js +24 -0
- package/dist/common/database/query-builder/constant/sql-keys.js.map +1 -0
- package/dist/common/database/query-builder/enum/filter.operator.enum.d.ts +20 -0
- package/dist/common/database/query-builder/enum/filter.operator.enum.js +25 -0
- package/dist/common/database/query-builder/enum/filter.operator.enum.js.map +1 -0
- package/dist/common/database/query-builder/enum/index.d.ts +2 -0
- package/dist/common/database/query-builder/enum/index.js +19 -0
- package/dist/common/database/query-builder/enum/index.js.map +1 -0
- package/dist/common/database/query-builder/enum/logical.operator.enum.d.ts +5 -0
- package/dist/common/database/query-builder/enum/logical.operator.enum.js +10 -0
- package/dist/common/database/query-builder/enum/logical.operator.enum.js.map +1 -0
- package/dist/common/database/query-builder/index.d.ts +7 -0
- package/dist/common/database/query-builder/index.js +24 -0
- package/dist/common/database/query-builder/index.js.map +1 -0
- package/dist/common/database/query-builder/options/find.option.d.ts +18 -0
- package/dist/common/database/query-builder/options/find.option.js +105 -0
- package/dist/common/database/query-builder/options/find.option.js.map +1 -0
- package/dist/common/database/query-builder/options/index.d.ts +5 -0
- package/dist/common/database/query-builder/options/index.js +22 -0
- package/dist/common/database/query-builder/options/index.js.map +1 -0
- package/dist/common/database/query-builder/options/order.option.d.ts +4 -0
- package/dist/common/database/query-builder/options/order.option.js +3 -0
- package/dist/common/database/query-builder/options/order.option.js.map +1 -0
- package/dist/common/database/query-builder/options/relation.option.d.ts +4 -0
- package/dist/common/database/query-builder/options/relation.option.js +3 -0
- package/dist/common/database/query-builder/options/relation.option.js.map +1 -0
- package/dist/common/database/query-builder/options/select.option.d.ts +3 -0
- package/dist/common/database/query-builder/options/select.option.js +3 -0
- package/dist/common/database/query-builder/options/select.option.js.map +1 -0
- package/dist/common/database/query-builder/options/where.option.d.ts +33 -0
- package/dist/common/database/query-builder/options/where.option.js +3 -0
- package/dist/common/database/query-builder/options/where.option.js.map +1 -0
- package/dist/common/database/query-builder/query-builder.d.ts +22 -0
- package/dist/common/database/query-builder/query-builder.js +105 -0
- package/dist/common/database/query-builder/query-builder.js.map +1 -0
- package/dist/common/database/query-builder/query-builder.module.d.ts +2 -0
- package/dist/common/database/query-builder/query-builder.module.js +31 -0
- package/dist/common/database/query-builder/query-builder.module.js.map +1 -0
- package/dist/common/database/query-builder/query-builder.provider.d.ts +26 -0
- package/dist/common/database/query-builder/query-builder.provider.js +126 -0
- package/dist/common/database/query-builder/query-builder.provider.js.map +1 -0
- package/dist/common/database/query-builder/query-form.d.ts +10 -0
- package/dist/common/database/query-builder/query-form.js +3 -0
- package/dist/common/database/query-builder/query-form.js.map +1 -0
- package/dist/common/database/query-builder/utils/add-and-operator.util.d.ts +2 -0
- package/dist/common/database/query-builder/utils/add-and-operator.util.js +26 -0
- package/dist/common/database/query-builder/utils/add-and-operator.util.js.map +1 -0
- package/dist/common/database/query-builder/utils/add-equal-operator.util.d.ts +2 -0
- package/dist/common/database/query-builder/utils/add-equal-operator.util.js +25 -0
- package/dist/common/database/query-builder/utils/add-equal-operator.util.js.map +1 -0
- package/dist/common/database/query-builder/utils/build-sql-where.util.d.ts +5 -0
- package/dist/common/database/query-builder/utils/build-sql-where.util.js +100 -0
- package/dist/common/database/query-builder/utils/build-sql-where.util.js.map +1 -0
- package/dist/common/database/query-builder/utils/convert-to-dot-notation.util.d.ts +1 -0
- package/dist/common/database/query-builder/utils/convert-to-dot-notation.util.js +30 -0
- package/dist/common/database/query-builder/utils/convert-to-dot-notation.util.js.map +1 -0
- package/dist/common/database/query-builder/utils/format-where.util.d.ts +2 -0
- package/dist/common/database/query-builder/utils/format-where.util.js +14 -0
- package/dist/common/database/query-builder/utils/format-where.util.js.map +1 -0
- package/dist/common/database/query-builder/utils/map-to-and-conditions.utils.d.ts +5 -0
- package/dist/common/database/query-builder/utils/map-to-and-conditions.utils.js +12 -0
- package/dist/common/database/query-builder/utils/map-to-and-conditions.utils.js.map +1 -0
- package/dist/common/database/query-builder/utils/qet-prop-selection.utils.d.ts +2 -0
- package/dist/common/database/query-builder/utils/qet-prop-selection.utils.js +25 -0
- package/dist/common/database/query-builder/utils/qet-prop-selection.utils.js.map +1 -0
- package/dist/common/database/query-builder/utils/qet-truthy-props.utils.d.ts +3 -0
- package/dist/common/database/query-builder/utils/qet-truthy-props.utils.js +10 -0
- package/dist/common/database/query-builder/utils/qet-truthy-props.utils.js.map +1 -0
- package/dist/common/database/query-builder/utils/query-builder.util.d.ts +13 -0
- package/dist/common/database/query-builder/utils/query-builder.util.js +31 -0
- package/dist/common/database/query-builder/utils/query-builder.util.js.map +1 -0
- package/dist/common/database/query-builder/utils/translate-query.utill.d.ts +4 -0
- package/dist/common/database/query-builder/utils/translate-query.utill.js +45 -0
- package/dist/common/database/query-builder/utils/translate-query.utill.js.map +1 -0
- package/dist/common/database/typeorm-connection.provider.js.map +1 -0
- package/dist/common/database/typeorm-unit-of-work/index.d.ts +0 -2
- package/dist/common/database/typeorm-unit-of-work/index.js +0 -2
- package/dist/common/database/typeorm-unit-of-work/index.js.map +1 -1
- package/dist/common/database/typeorm-unit-of-work/typeorm-unit-of-work.module.js +2 -2
- package/dist/common/database/typeorm-unit-of-work/typeorm-unit-of-work.module.js.map +1 -1
- package/dist/common/decorators/generic-get-by-id.decorator.js +4 -1
- package/dist/common/decorators/generic-get-by-id.decorator.js.map +1 -1
- package/dist/common/decorators/generic-get.decorator.js +4 -1
- package/dist/common/decorators/generic-get.decorator.js.map +1 -1
- package/dist/common/decorators/index.d.ts +1 -0
- package/dist/common/decorators/index.js +1 -0
- package/dist/common/decorators/index.js.map +1 -1
- package/dist/common/decorators/query-option.decorator.d.ts +1 -0
- package/dist/common/decorators/query-option.decorator.js +9 -0
- package/dist/common/decorators/query-option.decorator.js.map +1 -0
- package/dist/common/dto/search.dto.d.ts +5 -0
- package/dist/common/dto/search.dto.js +31 -1
- package/dist/common/dto/search.dto.js.map +1 -1
- package/dist/common/interceptors/index.d.ts +1 -0
- package/dist/common/interceptors/index.js +1 -0
- package/dist/common/interceptors/index.js.map +1 -1
- package/dist/common/interceptors/query.options.interceptor.d.ts +8 -0
- package/dist/common/interceptors/query.options.interceptor.js +31 -0
- package/dist/common/interceptors/query.options.interceptor.js.map +1 -0
- package/dist/common/interfaces/crud.controller.d.ts +3 -2
- package/dist/common/interfaces/crud.repository.d.ts +2 -2
- package/dist/common/interfaces/crud.service.d.ts +2 -2
- package/dist/common/parsers/index.d.ts +1 -0
- package/dist/common/parsers/index.js +18 -0
- package/dist/common/parsers/index.js.map +1 -0
- package/dist/common/parsers/query.parser.d.ts +10 -0
- package/dist/common/parsers/query.parser.js +40 -0
- package/dist/common/parsers/query.parser.js.map +1 -0
- package/dist/core/domain/generic.domain.factory.d.ts +1 -0
- package/dist/core/domain/generic.domain.factory.js +5 -0
- package/dist/core/domain/generic.domain.factory.js.map +1 -1
- package/dist/core/infra/iroh.repository.d.ts +7 -2
- package/dist/core/infra/iroh.repository.js +36 -28
- package/dist/core/infra/iroh.repository.js.map +1 -1
- package/dist/core/iroh.controller.js +3 -1
- package/dist/core/iroh.controller.js.map +1 -1
- package/dist/core/iroh.service.d.ts +2 -2
- package/dist/core/iroh.service.js.map +1 -1
- package/package.json +1 -1
- package/dist/common/database/typeorm-unit-of-work/data-source.provider.js.map +0 -1
- package/dist/common/database/typeorm-unit-of-work/typeorm-connection.provider.js.map +0 -1
- /package/dist/common/database/{typeorm-unit-of-work/data-source.provider.d.ts → data-source.provider.d.ts} +0 -0
- /package/dist/common/database/{typeorm-unit-of-work/data-source.provider.js → data-source.provider.js} +0 -0
- /package/dist/common/database/{typeorm-unit-of-work/typeorm-connection.provider.d.ts → typeorm-connection.provider.d.ts} +0 -0
- /package/dist/common/database/{typeorm-unit-of-work/typeorm-connection.provider.js → typeorm-connection.provider.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-source.provider.js","sourceRoot":"","sources":["../../../src/common/database/data-source.provider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAC7B,qCAAqC;AACrC,iDAA0D;AAE7C,QAAA,kBAAkB,GAAG;IAChC,OAAO,EAAE,oBAAU;IACnB,UAAU,EAAE,KAAK,IAAI,EAAE;QACrB,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;QAClC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QACnD,MAAM,UAAU,GAAG,IAAI,oBAAU,CAAC;YAChC,IAAI,EAAE,UAAU;YAChB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,OAAO;YACzB,IAAI,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO;YAC1B,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,OAAO;YAC7B,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW;YACjC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW;YACjC,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,MAAM;YAClD,QAAQ,EAAE,CAAC,QAAQ,GAAG,4BAA4B,CAAC;YACnD,cAAc,EAAE,IAAI,6BAAmB,EAAE;SAC1C,CAAC,CAAC;QAEH,IAAI,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC;YAC9B,MAAM,UAAU,CAAC,UAAU,EAAE,CAAC;QAChC,CAAC;QACD,OAAO,UAAU,CAAC;IACpB,CAAC;CACF,CAAC"}
|
|
@@ -15,4 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./typeorm-unit-of-work"), exports);
|
|
18
|
+
__exportStar(require("./query-builder"), exports);
|
|
19
|
+
__exportStar(require("./data-source.provider"), exports);
|
|
20
|
+
__exportStar(require("./typeorm-connection.provider"), exports);
|
|
18
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/database/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/database/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC;AACvC,kDAAgC;AAChC,yDAAuC;AACvC,gEAA8C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './sql-keys';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./sql-keys"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/common/database/query-builder/constant/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare const SQLKey: {
|
|
2
|
+
$eq: string;
|
|
3
|
+
$ne: string;
|
|
4
|
+
$gt: string;
|
|
5
|
+
$gte: string;
|
|
6
|
+
$lt: string;
|
|
7
|
+
$lte: string;
|
|
8
|
+
$in: string;
|
|
9
|
+
$nin: string;
|
|
10
|
+
$like: string;
|
|
11
|
+
$nlike: string;
|
|
12
|
+
$ilike: string;
|
|
13
|
+
$nilike: string;
|
|
14
|
+
$between: string;
|
|
15
|
+
$nbetween: string;
|
|
16
|
+
$regexp: string;
|
|
17
|
+
$iregexp: string;
|
|
18
|
+
$isnull: string;
|
|
19
|
+
$notnull: string;
|
|
20
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SQLKey = void 0;
|
|
4
|
+
exports.SQLKey = {
|
|
5
|
+
$eq: '=',
|
|
6
|
+
$ne: '<>',
|
|
7
|
+
$gt: '>',
|
|
8
|
+
$gte: '>=',
|
|
9
|
+
$lt: '<',
|
|
10
|
+
$lte: '<=',
|
|
11
|
+
$in: 'IN',
|
|
12
|
+
$nin: 'NOT IN',
|
|
13
|
+
$like: 'LIKE',
|
|
14
|
+
$nlike: 'NOT LIKE',
|
|
15
|
+
$ilike: 'ILIKE',
|
|
16
|
+
$nilike: 'NOT ILIKE',
|
|
17
|
+
$between: 'BETWEEN',
|
|
18
|
+
$nbetween: 'NOT BETWEEN',
|
|
19
|
+
$regexp: '~',
|
|
20
|
+
$iregexp: '~*',
|
|
21
|
+
$isnull: 'IS NULL',
|
|
22
|
+
$notnull: 'IS NOT NULL',
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=sql-keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sql-keys.js","sourceRoot":"","sources":["../../../../../src/common/database/query-builder/constant/sql-keys.ts"],"names":[],"mappings":";;;AAAa,QAAA,MAAM,GAAG;IACpB,GAAG,EAAE,GAAG;IACR,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,GAAG;IACR,IAAI,EAAE,IAAI;IACV,GAAG,EAAE,GAAG;IACR,IAAI,EAAE,IAAI;IACV,GAAG,EAAE,IAAI;IACT,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,MAAM;IACb,MAAM,EAAE,UAAU;IAClB,MAAM,EAAE,OAAO;IACf,OAAO,EAAE,WAAW;IACpB,QAAQ,EAAE,SAAS;IACnB,SAAS,EAAE,aAAa;IACxB,OAAO,EAAE,GAAG;IACZ,QAAQ,EAAE,IAAI;IACd,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,aAAa;CACxB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare enum FilterOperator {
|
|
2
|
+
eq = "$eq",
|
|
3
|
+
ne = "$ne",
|
|
4
|
+
gt = "$gt",
|
|
5
|
+
gte = "$gte",
|
|
6
|
+
lt = "$lt",
|
|
7
|
+
lte = "$lte",
|
|
8
|
+
in = "$in",
|
|
9
|
+
nin = "$nin",
|
|
10
|
+
like = "$like",
|
|
11
|
+
nlike = "$nlike",
|
|
12
|
+
ilike = "$ilike",
|
|
13
|
+
nilike = "$nilike",
|
|
14
|
+
between = "$between",
|
|
15
|
+
nbetween = "$nbetween",
|
|
16
|
+
regexp = "$regexp",
|
|
17
|
+
iregexp = "$iregexp",
|
|
18
|
+
isnull = "$isnull",
|
|
19
|
+
notnull = "$notnull"
|
|
20
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FilterOperator = void 0;
|
|
4
|
+
var FilterOperator;
|
|
5
|
+
(function (FilterOperator) {
|
|
6
|
+
FilterOperator["eq"] = "$eq";
|
|
7
|
+
FilterOperator["ne"] = "$ne";
|
|
8
|
+
FilterOperator["gt"] = "$gt";
|
|
9
|
+
FilterOperator["gte"] = "$gte";
|
|
10
|
+
FilterOperator["lt"] = "$lt";
|
|
11
|
+
FilterOperator["lte"] = "$lte";
|
|
12
|
+
FilterOperator["in"] = "$in";
|
|
13
|
+
FilterOperator["nin"] = "$nin";
|
|
14
|
+
FilterOperator["like"] = "$like";
|
|
15
|
+
FilterOperator["nlike"] = "$nlike";
|
|
16
|
+
FilterOperator["ilike"] = "$ilike";
|
|
17
|
+
FilterOperator["nilike"] = "$nilike";
|
|
18
|
+
FilterOperator["between"] = "$between";
|
|
19
|
+
FilterOperator["nbetween"] = "$nbetween";
|
|
20
|
+
FilterOperator["regexp"] = "$regexp";
|
|
21
|
+
FilterOperator["iregexp"] = "$iregexp";
|
|
22
|
+
FilterOperator["isnull"] = "$isnull";
|
|
23
|
+
FilterOperator["notnull"] = "$notnull";
|
|
24
|
+
})(FilterOperator || (exports.FilterOperator = FilterOperator = {}));
|
|
25
|
+
//# sourceMappingURL=filter.operator.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter.operator.enum.js","sourceRoot":"","sources":["../../../../../src/common/database/query-builder/enum/filter.operator.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,cAmBX;AAnBD,WAAY,cAAc;IACxB,4BAAU,CAAA;IACV,4BAAU,CAAA;IACV,4BAAU,CAAA;IACV,8BAAY,CAAA;IACZ,4BAAU,CAAA;IACV,8BAAY,CAAA;IACZ,4BAAU,CAAA;IACV,8BAAY,CAAA;IACZ,gCAAc,CAAA;IACd,kCAAgB,CAAA;IAChB,kCAAgB,CAAA;IAChB,oCAAkB,CAAA;IAClB,sCAAoB,CAAA;IACpB,wCAAsB,CAAA;IACtB,oCAAkB,CAAA;IAClB,sCAAoB,CAAA;IACpB,oCAAkB,CAAA;IAClB,sCAAoB,CAAA;AACtB,CAAC,EAnBW,cAAc,8BAAd,cAAc,QAmBzB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./filter.operator.enum"), exports);
|
|
18
|
+
__exportStar(require("./logical.operator.enum"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/common/database/query-builder/enum/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC;AACvC,0DAAwC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Op = void 0;
|
|
4
|
+
var Op;
|
|
5
|
+
(function (Op) {
|
|
6
|
+
Op["and"] = "$and";
|
|
7
|
+
Op["or"] = "$or";
|
|
8
|
+
Op["not"] = "$not";
|
|
9
|
+
})(Op || (exports.Op = Op = {}));
|
|
10
|
+
//# sourceMappingURL=logical.operator.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logical.operator.enum.js","sourceRoot":"","sources":["../../../../../src/common/database/query-builder/enum/logical.operator.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,EAIX;AAJD,WAAY,EAAE;IACZ,kBAAY,CAAA;IACZ,gBAAU,CAAA;IACV,kBAAY,CAAA;AACd,CAAC,EAJW,EAAE,kBAAF,EAAE,QAIb"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./constant"), exports);
|
|
18
|
+
__exportStar(require("./enum"), exports);
|
|
19
|
+
__exportStar(require("./options"), exports);
|
|
20
|
+
__exportStar(require("./query-builder.module"), exports);
|
|
21
|
+
__exportStar(require("./query-builder.provider"), exports);
|
|
22
|
+
__exportStar(require("./query-builder"), exports);
|
|
23
|
+
__exportStar(require("./query-form"), exports);
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/common/database/query-builder/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,yCAAuB;AACvB,4CAA0B;AAC1B,yDAAuC;AACvC,2DAAyC;AACzC,kDAAgC;AAChC,+CAA6B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Operator } from './where.option';
|
|
2
|
+
export declare const And: <T>(...operators: Operator<T>[]) => Operator<T>;
|
|
3
|
+
export declare const Equal: <T>(value: T) => Operator<T>;
|
|
4
|
+
export declare const NotEqual: <T>(value: T) => Operator<T>;
|
|
5
|
+
export declare const LessThan: <T>(value: T) => Operator<T>;
|
|
6
|
+
export declare const LessThanOrEqual: <T>(value: T) => Operator<T>;
|
|
7
|
+
export declare const MoreThan: <T>(value: T) => Operator<T>;
|
|
8
|
+
export declare const MoreThanOrEqual: <T>(value: T) => Operator<T>;
|
|
9
|
+
export declare const Like: <T>(value: string) => Operator<T>;
|
|
10
|
+
export declare const NotLike: <T>(value: string) => Operator<T>;
|
|
11
|
+
export declare const ILike: <T>(value: string) => Operator<T>;
|
|
12
|
+
export declare const NotILike: <T>(value: string) => Operator<T>;
|
|
13
|
+
export declare const Between: <T>(from: T, to: T) => Operator<T>;
|
|
14
|
+
export declare const NotBetween: <T>(from: T, to: T) => Operator<T>;
|
|
15
|
+
export declare const In: <T>(value: T[]) => Operator<T>;
|
|
16
|
+
export declare const NotIn: <T>(value: T[]) => Operator<T>;
|
|
17
|
+
export declare const IsNull: <T>() => Operator<T>;
|
|
18
|
+
export declare const NotIsNull: <T>() => Operator<T>;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotIsNull = exports.IsNull = exports.NotIn = exports.In = exports.NotBetween = exports.Between = exports.NotILike = exports.ILike = exports.NotLike = exports.Like = exports.MoreThanOrEqual = exports.MoreThan = exports.LessThanOrEqual = exports.LessThan = exports.NotEqual = exports.Equal = exports.And = void 0;
|
|
4
|
+
const enum_1 = require("../enum");
|
|
5
|
+
const And = (...operators) => {
|
|
6
|
+
return operators.reduce((ac, value) => ({ ...ac, ...value }), {});
|
|
7
|
+
};
|
|
8
|
+
exports.And = And;
|
|
9
|
+
const Equal = (value) => {
|
|
10
|
+
return {
|
|
11
|
+
[enum_1.FilterOperator.eq]: value,
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
exports.Equal = Equal;
|
|
15
|
+
const NotEqual = (value) => {
|
|
16
|
+
return {
|
|
17
|
+
[enum_1.FilterOperator.ne]: value,
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
exports.NotEqual = NotEqual;
|
|
21
|
+
const LessThan = (value) => {
|
|
22
|
+
return {
|
|
23
|
+
[enum_1.FilterOperator.lt]: value,
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
exports.LessThan = LessThan;
|
|
27
|
+
const LessThanOrEqual = (value) => {
|
|
28
|
+
return {
|
|
29
|
+
[enum_1.FilterOperator.lte]: value,
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
exports.LessThanOrEqual = LessThanOrEqual;
|
|
33
|
+
const MoreThan = (value) => {
|
|
34
|
+
return {
|
|
35
|
+
[enum_1.FilterOperator.gt]: value,
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
exports.MoreThan = MoreThan;
|
|
39
|
+
const MoreThanOrEqual = (value) => {
|
|
40
|
+
return {
|
|
41
|
+
[enum_1.FilterOperator.gte]: value,
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
exports.MoreThanOrEqual = MoreThanOrEqual;
|
|
45
|
+
const Like = (value) => {
|
|
46
|
+
return {
|
|
47
|
+
[enum_1.FilterOperator.like]: value,
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
exports.Like = Like;
|
|
51
|
+
const NotLike = (value) => {
|
|
52
|
+
return {
|
|
53
|
+
[enum_1.FilterOperator.nlike]: value,
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
exports.NotLike = NotLike;
|
|
57
|
+
const ILike = (value) => {
|
|
58
|
+
return {
|
|
59
|
+
[enum_1.FilterOperator.ilike]: value,
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
exports.ILike = ILike;
|
|
63
|
+
const NotILike = (value) => {
|
|
64
|
+
return {
|
|
65
|
+
[enum_1.FilterOperator.nilike]: value,
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
exports.NotILike = NotILike;
|
|
69
|
+
const Between = (from, to) => {
|
|
70
|
+
return {
|
|
71
|
+
[enum_1.FilterOperator.between]: [from, to],
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
exports.Between = Between;
|
|
75
|
+
const NotBetween = (from, to) => {
|
|
76
|
+
return {
|
|
77
|
+
[enum_1.FilterOperator.nbetween]: [from, to],
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
exports.NotBetween = NotBetween;
|
|
81
|
+
const In = (value) => {
|
|
82
|
+
return {
|
|
83
|
+
[enum_1.FilterOperator.in]: value,
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
exports.In = In;
|
|
87
|
+
const NotIn = (value) => {
|
|
88
|
+
return {
|
|
89
|
+
[enum_1.FilterOperator.nin]: value,
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
exports.NotIn = NotIn;
|
|
93
|
+
const IsNull = () => {
|
|
94
|
+
return {
|
|
95
|
+
[enum_1.FilterOperator.isnull]: true,
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
exports.IsNull = IsNull;
|
|
99
|
+
const NotIsNull = () => {
|
|
100
|
+
return {
|
|
101
|
+
[enum_1.FilterOperator.notnull]: true,
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
exports.NotIsNull = NotIsNull;
|
|
105
|
+
//# sourceMappingURL=find.option.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find.option.js","sourceRoot":"","sources":["../../../../../src/common/database/query-builder/options/find.option.ts"],"names":[],"mappings":";;;AAAA,kCAAyC;AAGlC,MAAM,GAAG,GAAG,CAAI,GAAG,SAAwB,EAAe,EAAE;IACjE,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;AACpE,CAAC,CAAC;AAFW,QAAA,GAAG,OAEd;AACK,MAAM,KAAK,GAAG,CAAI,KAAQ,EAAe,EAAE;IAChD,OAAO;QACL,CAAC,qBAAc,CAAC,EAAE,CAAC,EAAE,KAAK;KAC3B,CAAC;AACJ,CAAC,CAAC;AAJW,QAAA,KAAK,SAIhB;AAEK,MAAM,QAAQ,GAAG,CAAI,KAAQ,EAAe,EAAE;IACnD,OAAO;QACL,CAAC,qBAAc,CAAC,EAAE,CAAC,EAAE,KAAK;KAC3B,CAAC;AACJ,CAAC,CAAC;AAJW,QAAA,QAAQ,YAInB;AAEK,MAAM,QAAQ,GAAG,CAAI,KAAQ,EAAe,EAAE;IACnD,OAAO;QACL,CAAC,qBAAc,CAAC,EAAE,CAAC,EAAE,KAAK;KAC3B,CAAC;AACJ,CAAC,CAAC;AAJW,QAAA,QAAQ,YAInB;AAEK,MAAM,eAAe,GAAG,CAAI,KAAQ,EAAe,EAAE;IAC1D,OAAO;QACL,CAAC,qBAAc,CAAC,GAAG,CAAC,EAAE,KAAK;KAC5B,CAAC;AACJ,CAAC,CAAC;AAJW,QAAA,eAAe,mBAI1B;AAEK,MAAM,QAAQ,GAAG,CAAI,KAAQ,EAAe,EAAE;IACnD,OAAO;QACL,C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AAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC;KACtC,CAAC;AACJ,CAAC,CAAC;AAJW,QAAA,UAAU,cAIrB;AAEK,MAAM,EAAE,GAAG,CAAI,KAAU,EAAe,EAAE;IAC/C,OAAO;QACL,CAAC,qBAAc,CAAC,EAAE,CAAC,EAAE,KAAK;KAC3B,CAAC;AACJ,CAAC,CAAC;AAJW,QAAA,EAAE,MAIb;AAEK,MAAM,KAAK,GAAG,CAAI,KAAU,EAAe,EAAE;IAClD,OAAO;QACL,CAAC,qBAAc,CAAC,GAAG,CAAC,EAAE,KAAK;KAC5B,CAAC;AACJ,CAAC,CAAC;AAJW,QAAA,KAAK,SAIhB;AAEK,MAAM,MAAM,GAAG,GAAmB,EAAE;IACzC,OAAO;QACL,CAAC,qBAAc,CAAC,MAAM,CAAC,EAAE,IAAI;KAC9B,CAAC;AACJ,CAAC,CAAC;AAJW,QAAA,MAAM,UAIjB;AAEK,MAAM,SAAS,GAAG,GAAmB,EAAE;IAC5C,OAAO;QACL,CAAC,qBAAc,CAAC,OAAO,CAAC,EAAE,IAAW;KACtC,CAAC;AACJ,CAAC,CAAC;AAJW,QAAA,SAAS,aAIpB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./find.option"), exports);
|
|
18
|
+
__exportStar(require("./order.option"), exports);
|
|
19
|
+
__exportStar(require("./relation.option"), exports);
|
|
20
|
+
__exportStar(require("./select.option"), exports);
|
|
21
|
+
__exportStar(require("./where.option"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/common/database/query-builder/options/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,iDAA+B;AAC/B,oDAAkC;AAClC,kDAAgC;AAChC,iDAA+B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order.option.js","sourceRoot":"","sources":["../../../../../src/common/database/query-builder/options/order.option.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type FindOptionsRelationsProperty<Property> = Property extends Promise<infer I> ? FindOptionsRelationsProperty<NonNullable<I>> | boolean : Property extends Array<infer I> ? FindOptionsRelationsProperty<NonNullable<I>> | boolean : Property extends string ? never : Property extends number ? never : Property extends boolean ? never : Property extends Function ? never : Property extends Buffer ? never : Property extends Date ? never : Property extends object ? RelationOption<Property> | boolean : boolean;
|
|
2
|
+
export type RelationOption<Entity> = {
|
|
3
|
+
[P in keyof Entity]?: P extends 'toString' ? unknown : FindOptionsRelationsProperty<NonNullable<Entity[P]>>;
|
|
4
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relation.option.js","sourceRoot":"","sources":["../../../../../src/common/database/query-builder/options/relation.option.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select.option.js","sourceRoot":"","sources":["../../../../../src/common/database/query-builder/options/select.option.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export type WhereOption<T = any> = {
|
|
2
|
+
[P in keyof T]?: T[P] extends Array<infer I> ? Property<I> : T[P] extends object ? Property<T[P]> : Operator<T[P]>;
|
|
3
|
+
} | {
|
|
4
|
+
$and?: WhereOption<T>[];
|
|
5
|
+
} | {
|
|
6
|
+
$or?: WhereOption<T>[];
|
|
7
|
+
} | {
|
|
8
|
+
$not?: WhereOption<T>;
|
|
9
|
+
};
|
|
10
|
+
type Property<T> = {
|
|
11
|
+
[P in keyof T]?: T[P] extends Array<infer I> ? Property<I> : T[P] extends object ? Property<P> : Operator<T[P]>;
|
|
12
|
+
};
|
|
13
|
+
export type Operator<T> = {
|
|
14
|
+
$eq?: T;
|
|
15
|
+
$ne?: T;
|
|
16
|
+
$gt?: T;
|
|
17
|
+
$gte?: T;
|
|
18
|
+
$lt?: T;
|
|
19
|
+
$lte?: T;
|
|
20
|
+
$in?: T[];
|
|
21
|
+
$nin?: T[];
|
|
22
|
+
$like?: string;
|
|
23
|
+
$nlike?: string;
|
|
24
|
+
$ilike?: string;
|
|
25
|
+
$nilike?: string;
|
|
26
|
+
$between?: [T, T];
|
|
27
|
+
$nbetween?: [T, T];
|
|
28
|
+
$regexp?: RegExp | string;
|
|
29
|
+
$iregexp?: RegExp | string;
|
|
30
|
+
$isnull?: true;
|
|
31
|
+
$notnull?: true;
|
|
32
|
+
} | T;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"where.option.js","sourceRoot":"","sources":["../../../../../src/common/database/query-builder/options/where.option.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SelectQueryBuilder } from 'typeorm';
|
|
2
|
+
import { QueryForm } from './query-form';
|
|
3
|
+
import { SelectOption } from './options/select.option';
|
|
4
|
+
import { RelationOption } from './options/relation.option';
|
|
5
|
+
import { WhereOption } from './options/where.option';
|
|
6
|
+
import { OrderOption } from './options/order.option';
|
|
7
|
+
export declare class QueryBuilder<T> {
|
|
8
|
+
private alias;
|
|
9
|
+
private builder;
|
|
10
|
+
constructor(sqb: SelectQueryBuilder<T>);
|
|
11
|
+
addOptions(form: QueryForm<T>): void;
|
|
12
|
+
getMany(): Promise<T[]>;
|
|
13
|
+
getOne(): Promise<T>;
|
|
14
|
+
getCount(): Promise<number>;
|
|
15
|
+
getSql(): string;
|
|
16
|
+
addRelations(relations: RelationOption<T>, alias?: string): void;
|
|
17
|
+
addSelect(options: SelectOption<T>, alias?: string): void;
|
|
18
|
+
addWhere(whereOptions: WhereOption<T>, alias?: string): void;
|
|
19
|
+
addOrder(orderOptions: OrderOption<T>, alias?: string): void;
|
|
20
|
+
addLimit(limit: number): void;
|
|
21
|
+
addOffset(offset: number): void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QueryBuilder = void 0;
|
|
4
|
+
const query_builder_util_1 = require("./utils/query-builder.util");
|
|
5
|
+
class QueryBuilder {
|
|
6
|
+
constructor(sqb) {
|
|
7
|
+
this.alias = 'alias';
|
|
8
|
+
this.builder = sqb;
|
|
9
|
+
}
|
|
10
|
+
addOptions(form) {
|
|
11
|
+
if (typeof form.relations === 'object') {
|
|
12
|
+
this.addRelations(form.relations);
|
|
13
|
+
}
|
|
14
|
+
const selectOptions = query_builder_util_1.QueryBuilderUtil.getPropSelection(form.relations, form.select);
|
|
15
|
+
this.addSelect(selectOptions);
|
|
16
|
+
if (typeof form.where === 'object') {
|
|
17
|
+
this.addWhere(form.where);
|
|
18
|
+
}
|
|
19
|
+
if (typeof form.order === 'object') {
|
|
20
|
+
this.addOrder(form.order);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
getMany() {
|
|
24
|
+
return this.builder.getMany();
|
|
25
|
+
}
|
|
26
|
+
getOne() {
|
|
27
|
+
return this.builder.getOne();
|
|
28
|
+
}
|
|
29
|
+
getCount() {
|
|
30
|
+
return this.builder.getCount();
|
|
31
|
+
}
|
|
32
|
+
getSql() {
|
|
33
|
+
return this.builder.getSql();
|
|
34
|
+
}
|
|
35
|
+
addRelations(relations, alias = this.alias) {
|
|
36
|
+
for (const [key, value] of Object.entries(relations)) {
|
|
37
|
+
const newAlias = `${alias}_${key}`;
|
|
38
|
+
if (value === true) {
|
|
39
|
+
this.builder.leftJoin(`${alias}.${key}`, newAlias);
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (typeof value === 'object' && value !== null) {
|
|
43
|
+
this.builder.leftJoin(`${alias}.${key}`, newAlias);
|
|
44
|
+
this.addRelations(value, newAlias);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
addSelect(options, alias = this.alias) {
|
|
49
|
+
const values = Object.values(options);
|
|
50
|
+
const all = values.every((value) => value !== true);
|
|
51
|
+
if (all) {
|
|
52
|
+
this.builder.addSelect(alias);
|
|
53
|
+
}
|
|
54
|
+
for (const prop in options) {
|
|
55
|
+
const value = options[prop];
|
|
56
|
+
const isObject = typeof value === 'object';
|
|
57
|
+
switch (true) {
|
|
58
|
+
case isObject:
|
|
59
|
+
{
|
|
60
|
+
const newAlias = `${alias}_${prop}`;
|
|
61
|
+
this.addSelect(value, newAlias);
|
|
62
|
+
}
|
|
63
|
+
break;
|
|
64
|
+
case value === true:
|
|
65
|
+
this.builder.addSelect(`${alias}.${prop}`);
|
|
66
|
+
break;
|
|
67
|
+
default:
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
addWhere(whereOptions, alias = this.alias) {
|
|
73
|
+
const params = {};
|
|
74
|
+
const where = query_builder_util_1.QueryBuilderUtil.formatWhere(whereOptions);
|
|
75
|
+
const sqlScript = query_builder_util_1.QueryBuilderUtil.buildSQLWhere(alias, where, params);
|
|
76
|
+
this.builder.where(sqlScript).setParameters(params);
|
|
77
|
+
}
|
|
78
|
+
addOrder(orderOptions, alias = this.alias) {
|
|
79
|
+
const orderTypes = ['ASC', 'DESC'];
|
|
80
|
+
for (const field in orderOptions) {
|
|
81
|
+
const orderField = orderOptions[field];
|
|
82
|
+
if (orderField) {
|
|
83
|
+
if (typeof orderField === 'object') {
|
|
84
|
+
const newAlias = `${alias}_${field}`;
|
|
85
|
+
this.addOrder(orderOptions[field], newAlias);
|
|
86
|
+
}
|
|
87
|
+
else if (orderTypes.includes(orderField)) {
|
|
88
|
+
this.builder.addOrderBy(`${alias}.${field}`, orderField);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
addLimit(limit) {
|
|
94
|
+
if (limit) {
|
|
95
|
+
this.builder.limit(Number(limit));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
addOffset(offset) {
|
|
99
|
+
if (offset) {
|
|
100
|
+
this.builder.offset(Number(offset));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.QueryBuilder = QueryBuilder;
|
|
105
|
+
//# sourceMappingURL=query-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-builder.js","sourceRoot":"","sources":["../../../../src/common/database/query-builder/query-builder.ts"],"names":[],"mappings":";;;AAOA,mEAA8D;AAE9D,MAAa,YAAY;IAIvB,YAAY,GAA0B;QAH9B,UAAK,GAAW,OAAO,CAAC;QAI9B,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC;IACrB,CAAC;IAEM,UAAU,CAAC,IAAkB;QAClC,IAAI,OAAO,IAAI,CAAC,SAAS,KAAK,QAAQ,EAAE,CAAC;YACvC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACpC,CAAC;QAED,MAAM,aAAa,GAAG,qCAAgB,CAAC,gBAAgB,CACrD,IAAI,CAAC,SA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