nicot 1.0.40 → 1.0.41
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.
|
@@ -4,3 +4,4 @@ export declare const QueryEqual: () => import("typed-reflector").AllDecorators;
|
|
|
4
4
|
export declare const QueryLike: () => import("typed-reflector").AllDecorators;
|
|
5
5
|
export declare const QuerySearch: () => import("typed-reflector").AllDecorators;
|
|
6
6
|
export declare const QueryEqualZeroNullable: () => import("typed-reflector").AllDecorators;
|
|
7
|
+
export declare const QueryMatchBoolean: () => import("typed-reflector").AllDecorators;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.QueryEqualZeroNullable = exports.QuerySearch = exports.QueryLike = exports.QueryEqual = exports.QueryCondition = void 0;
|
|
3
|
+
exports.QueryMatchBoolean = exports.QueryEqualZeroNullable = exports.QuerySearch = exports.QueryLike = exports.QueryEqual = exports.QueryCondition = void 0;
|
|
4
4
|
const metadata_1 = require("../utility/metadata");
|
|
5
5
|
const utility_1 = require("../utility");
|
|
6
6
|
const QueryCondition = (cond) => metadata_1.Metadata.set('queryCondition', cond, 'queryConditionFields');
|
|
@@ -13,4 +13,6 @@ const QuerySearch = () => (0, exports.QueryCondition)(utility_1.applyQueryProper
|
|
|
13
13
|
exports.QuerySearch = QuerySearch;
|
|
14
14
|
const QueryEqualZeroNullable = () => (0, exports.QueryCondition)(utility_1.applyQueryPropertyZeroNullable);
|
|
15
15
|
exports.QueryEqualZeroNullable = QueryEqualZeroNullable;
|
|
16
|
+
const QueryMatchBoolean = () => (0, exports.QueryCondition)(utility_1.applyQueryMatchBoolean);
|
|
17
|
+
exports.QueryMatchBoolean = QueryMatchBoolean;
|
|
16
18
|
//# sourceMappingURL=query.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../../src/decorators/query.ts"],"names":[],"mappings":";;;AACA,kDAA+C;AAC/C,
|
|
1
|
+
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../../src/decorators/query.ts"],"names":[],"mappings":";;;AACA,kDAA+C;AAC/C,wCAMoB;AAEb,MAAM,cAAc,GAAG,CAAC,IAAe,EAAE,EAAE,CAChD,mBAAQ,CAAC,GAAG,CAAC,gBAAgB,EAAE,IAAI,EAAE,sBAAsB,CAAC,CAAC;AADlD,QAAA,cAAc,kBACoC;AACxD,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,IAAA,sBAAc,EAAC,4BAAkB,CAAC,CAAC;AAAtD,QAAA,UAAU,cAA4C;AAC5D,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,IAAA,sBAAc,EAAC,gCAAsB,CAAC,CAAC;AAAzD,QAAA,SAAS,aAAgD;AAC/D,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC,IAAA,sBAAc,EAAC,kCAAwB,CAAC,CAAC;AAA7D,QAAA,WAAW,eAAkD;AAEnE,MAAM,sBAAsB,GAAG,GAAG,EAAE,CACzC,IAAA,sBAAc,EAAC,wCAA8B,CAAC,CAAC;AADpC,QAAA,sBAAsB,0BACc;AAE1C,MAAM,iBAAiB,GAAG,GAAG,EAAE,CAAC,IAAA,sBAAc,EAAC,gCAAsB,CAAC,CAAC;AAAjE,QAAA,iBAAiB,qBAAgD"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { SelectQueryBuilder } from 'typeorm';
|
|
2
|
-
export declare function
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
export declare function createQueryCondition(cond: <T>(obj: T, qb: SelectQueryBuilder<T>, entityName: string, field: keyof T & string) => void | SelectQueryBuilder<any> | string | {
|
|
3
|
+
query: string;
|
|
4
|
+
params: Record<string, any>;
|
|
5
|
+
}): <T>(obj: T, qb: SelectQueryBuilder<T>, entityName: string, ...fields: (keyof T & string)[]) => SelectQueryBuilder<T>;
|
|
6
|
+
export declare const applyQueryProperty: <T>(obj: T, qb: SelectQueryBuilder<T>, entityName: string, ...fields: (keyof T & string)[]) => SelectQueryBuilder<T>;
|
|
7
|
+
export declare const applyQueryPropertyLike: <T>(obj: T, qb: SelectQueryBuilder<T>, entityName: string, ...fields: (keyof T & string)[]) => SelectQueryBuilder<T>;
|
|
8
|
+
export declare const applyQueryPropertySearch: <T>(obj: T, qb: SelectQueryBuilder<T>, entityName: string, ...fields: (keyof T & string)[]) => SelectQueryBuilder<T>;
|
|
9
|
+
export declare const applyQueryPropertyZeroNullable: <T>(obj: T, qb: SelectQueryBuilder<T>, entityName: string, ...fields: (keyof T & string)[]) => SelectQueryBuilder<T>;
|
|
10
|
+
export declare const applyQueryMatchBoolean: <T>(obj: T, qb: SelectQueryBuilder<T>, entityName: string, ...fields: (keyof T & string)[]) => SelectQueryBuilder<T>;
|
|
@@ -1,51 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.applyQueryPropertyZeroNullable = exports.applyQueryPropertySearch = exports.applyQueryPropertyLike = exports.applyQueryProperty = void 0;
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
exports.applyQueryMatchBoolean = exports.applyQueryPropertyZeroNullable = exports.applyQueryPropertySearch = exports.applyQueryPropertyLike = exports.applyQueryProperty = exports.createQueryCondition = void 0;
|
|
4
|
+
function createQueryCondition(cond) {
|
|
5
|
+
return (obj, qb, entityName, ...fields) => {
|
|
6
|
+
for (const field of fields) {
|
|
7
|
+
if (obj[field] == null) {
|
|
8
|
+
continue;
|
|
9
|
+
}
|
|
10
|
+
const ret = cond(obj, qb, entityName, field);
|
|
11
|
+
if (typeof ret === 'string') {
|
|
12
|
+
qb.andWhere(ret);
|
|
13
|
+
}
|
|
14
|
+
else if (typeof ret === 'object' && typeof ret['query'] === 'string') {
|
|
15
|
+
const _ret = ret;
|
|
16
|
+
qb.andWhere(_ret.query, _ret.params);
|
|
17
|
+
}
|
|
8
18
|
}
|
|
9
|
-
qb
|
|
10
|
-
}
|
|
19
|
+
return qb;
|
|
20
|
+
};
|
|
11
21
|
}
|
|
12
|
-
exports.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
exports.createQueryCondition = createQueryCondition;
|
|
23
|
+
exports.applyQueryProperty = createQueryCondition((obj, qb, entityName, field) => qb.andWhere(`${entityName}.${field} = :${field}`, { [field]: obj[field] }));
|
|
24
|
+
exports.applyQueryPropertyLike = createQueryCondition((obj, qb, entityName, field) => qb.andWhere(`${entityName}.${field} like (:${field} || '%')`, {
|
|
25
|
+
[field]: obj[field],
|
|
26
|
+
}));
|
|
27
|
+
exports.applyQueryPropertySearch = createQueryCondition((obj, qb, entityName, field) => qb.andWhere(`${entityName}.${field} like ('%' || :${field} || '%')`, {
|
|
28
|
+
[field]: obj[field],
|
|
29
|
+
}));
|
|
30
|
+
exports.applyQueryPropertyZeroNullable = createQueryCondition((obj, qb, entityName, field) => {
|
|
31
|
+
if ([0, '0'].indexOf(obj[field]) !== -1) {
|
|
32
|
+
qb.andWhere(`${entityName}.${field} IS NULL`);
|
|
21
33
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
function applyQueryPropertySearch(obj, qb, entityName, ...fields) {
|
|
25
|
-
for (const field of fields) {
|
|
26
|
-
if (obj[field] == null) {
|
|
27
|
-
continue;
|
|
28
|
-
}
|
|
29
|
-
qb.andWhere(`${entityName}.${field} like ('%' || :${field} || '%')`, {
|
|
34
|
+
else {
|
|
35
|
+
qb.andWhere(`${entityName}.${field} = :${field}`, {
|
|
30
36
|
[field]: obj[field],
|
|
31
37
|
});
|
|
32
38
|
}
|
|
33
|
-
}
|
|
34
|
-
exports.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
// Nothing
|
|
39
|
-
}
|
|
40
|
-
else if ([0, '0'].indexOf(obj[field]) !== -1) {
|
|
41
|
-
qb.andWhere(`${entityName}.${field} IS NULL`);
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
qb.andWhere(`${entityName}.${field} = :${field}`, {
|
|
45
|
-
[field]: obj[field],
|
|
46
|
-
});
|
|
47
|
-
}
|
|
39
|
+
});
|
|
40
|
+
exports.applyQueryMatchBoolean = createQueryCondition((obj, qb, entityName, field) => {
|
|
41
|
+
const value = obj[field];
|
|
42
|
+
if (value === true || value === 'true' || value === 1 || value === '1') {
|
|
43
|
+
qb.andWhere(`${entityName}.${field} = TRUE`);
|
|
48
44
|
}
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
if (value === false || value === 'false' || value === 0 || value === '0') {
|
|
46
|
+
qb.andWhere(`${entityName}.${field} = FALSE`);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
51
49
|
//# sourceMappingURL=query.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../../src/utility/query.ts"],"names":[],"mappings":";;;AAEA,SAAgB,
|
|
1
|
+
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../../src/utility/query.ts"],"names":[],"mappings":";;;AAEA,SAAgB,oBAAoB,CAClC,IASkD;IAElD,OAAO,CACL,GAAM,EACN,EAAyB,EACzB,UAAkB,EAClB,GAAG,MAA4B,EAC/B,EAAE;QACF,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;YAC1B,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE;gBACtB,SAAS;aACV;YACD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,EAAE,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;YAC7C,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;gBAC3B,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;aAClB;iBAAM,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,OAAO,GAA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