@dataui/crud-typeorm
Advanced tools
Comparing version 5.2.3 to 5.2.4
@@ -54,3 +54,3 @@ import { CreateManyDto, CrudRequest, CrudRequestOptions, CrudService, CustomOperators, GetManyDefaultResponse, JoinOption, JoinOptions, QueryOptions } from '@dataui/crud'; | ||
protected setSearchCondition(builder: SelectQueryBuilder<T>, search: SCondition, customOperators: CustomOperators, condition?: SConditionKey): void; | ||
protected builderAddBrackets(builder: SelectQueryBuilder<T>, condition: SConditionKey, brackets: Brackets): void; | ||
protected builderAddBrackets(builder: SelectQueryBuilder<T>, condition: SConditionKey, brackets: Brackets, negated?: boolean): void; | ||
protected builderSetWhere(builder: SelectQueryBuilder<T>, condition: SConditionKey, field: string, value: any, customOperators: CustomOperators, operator?: ComparisonOperator): void; | ||
@@ -57,0 +57,0 @@ protected setSearchFieldObjectCondition(builder: SelectQueryBuilder<T>, condition: SConditionKey, field: string, object: any, customOperators: CustomOperators): void; |
@@ -400,3 +400,10 @@ "use strict"; | ||
if (keys.length) { | ||
if (crud_util_1.isArrayFull(search.$and)) { | ||
if (crud_util_1.isArrayFull(search.$not)) { | ||
this.builderAddBrackets(builder, condition, new typeorm_1.Brackets((qb) => { | ||
search.$not.forEach((item) => { | ||
this.setSearchCondition(qb, item, customOperators, '$and'); | ||
}); | ||
}), true); | ||
} | ||
else if (crud_util_1.isArrayFull(search.$and)) { | ||
if (search.$and.length === 1) { | ||
@@ -482,4 +489,28 @@ this.setSearchCondition(builder, search.$and[0], customOperators, condition); | ||
} | ||
builderAddBrackets(builder, condition, brackets) { | ||
if (condition === '$and') { | ||
builderAddBrackets(builder, condition, brackets, negated = false) { | ||
if (negated) { | ||
const whereQueryBuilder = builder.createQueryBuilder(); | ||
whereQueryBuilder.parentQueryBuilder = builder; | ||
whereQueryBuilder.expressionMap.mainAlias = builder.expressionMap.mainAlias; | ||
whereQueryBuilder.expressionMap.aliasNamePrefixingEnabled = | ||
builder.expressionMap.aliasNamePrefixingEnabled; | ||
whereQueryBuilder.expressionMap.parameters = builder.expressionMap.parameters; | ||
whereQueryBuilder.expressionMap.nativeParameters = | ||
builder.expressionMap.nativeParameters; | ||
whereQueryBuilder.expressionMap.wheres = []; | ||
brackets.whereFactory(whereQueryBuilder); | ||
const wheres = { | ||
operator: 'brackets', | ||
condition: whereQueryBuilder.expressionMap.wheres, | ||
}; | ||
const type = condition === '$and' ? 'and' : condition === '$or' ? 'or' : 'simple'; | ||
builder.expressionMap.wheres.push({ | ||
type, | ||
condition: { | ||
operator: 'not', | ||
condition: wheres, | ||
}, | ||
}); | ||
} | ||
else if (condition === '$and') { | ||
builder.andWhere(brackets); | ||
@@ -486,0 +517,0 @@ } |
{ | ||
"name": "@dataui/crud-typeorm", | ||
"description": "NestJs CRUD for RESTful APIs - TypeORM", | ||
"version": "5.2.3", | ||
"version": "5.2.4", | ||
"license": "MIT", | ||
@@ -45,3 +45,3 @@ "main": "lib/index.js", | ||
}, | ||
"gitHead": "25b0f851a96305c0dbe8cb91cb9e88ad9284e63c" | ||
"gitHead": "6d86d565bdc1286689c7f840e37fbf38b51a29a3" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
75997
836