修改了残留的查询写法
This commit is contained in:
parent
4258628400
commit
a8e7d54e1e
|
|
@ -778,7 +778,7 @@ var CascadeStore = /** @class */ (function (_super) {
|
||||||
option2.modiParentEntity = entity;
|
option2.modiParentEntity = entity;
|
||||||
}
|
}
|
||||||
var _loop_2 = function (attr) {
|
var _loop_2 = function (attr) {
|
||||||
var _a, _b, _c, e_2, _d;
|
var _a, _b, _c, _d, e_2, _e;
|
||||||
var relation = (0, relation_1.judgeRelation)(this_2.storageSchema, entity, attr);
|
var relation = (0, relation_1.judgeRelation)(this_2.storageSchema, entity, attr);
|
||||||
if (relation === 1) {
|
if (relation === 1) {
|
||||||
Object.assign(opData, (_a = {},
|
Object.assign(opData, (_a = {},
|
||||||
|
|
@ -834,19 +834,11 @@ var CascadeStore = /** @class */ (function (_super) {
|
||||||
else {
|
else {
|
||||||
// A中data的entityId作为B中filter的主键
|
// A中data的entityId作为B中filter的主键
|
||||||
Object.assign(operationMto_1, {
|
Object.assign(operationMto_1, {
|
||||||
filter: (0, filter_1.addFilterSegment)({
|
filter: (0, filter_1.addFilterSegment)((_b = {},
|
||||||
id: {
|
_b["".concat(entity, "$entity")] = {
|
||||||
$in: {
|
filter: filter,
|
||||||
entity: entity,
|
|
||||||
data: {
|
|
||||||
entityId: 1,
|
|
||||||
},
|
},
|
||||||
filter: (0, filter_1.addFilterSegment)({
|
_b), filterMto),
|
||||||
entity: attr,
|
|
||||||
}, filter),
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}, filterMto),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -857,12 +849,12 @@ var CascadeStore = /** @class */ (function (_super) {
|
||||||
var operationMto_2 = data[attr];
|
var operationMto_2 = data[attr];
|
||||||
var actionMto = operationMto_2.action, dataMto = operationMto_2.data, filterMto = operationMto_2.filter;
|
var actionMto = operationMto_2.action, dataMto = operationMto_2.data, filterMto = operationMto_2.filter;
|
||||||
if (actionMto === 'create') {
|
if (actionMto === 'create') {
|
||||||
Object.assign(opData, (_b = {},
|
Object.assign(opData, (_c = {},
|
||||||
_b["".concat(attr, "Id")] = dataMto.id,
|
_c["".concat(attr, "Id")] = dataMto.id,
|
||||||
_b));
|
_c));
|
||||||
}
|
}
|
||||||
else if (action === 'create') {
|
else if (action === 'create') {
|
||||||
var _e = data, _f = "".concat(attr, "Id"), fkId = _e[_f];
|
var _f = data, _g = "".concat(attr, "Id"), fkId = _f[_g];
|
||||||
(0, assert_1.default)(typeof fkId === 'string');
|
(0, assert_1.default)(typeof fkId === 'string');
|
||||||
if (filterMto === null || filterMto === void 0 ? void 0 : filterMto.id) {
|
if (filterMto === null || filterMto === void 0 ? void 0 : filterMto.id) {
|
||||||
// 若已有id则不用处理,否则会干扰modi的后续判断(会根据filter来判断对象id,如果判断不出来去查实际的对象,但实际的对象其实还未创建好)
|
// 若已有id则不用处理,否则会干扰modi的后续判断(会根据filter来判断对象id,如果判断不出来去查实际的对象,但实际的对象其实还未创建好)
|
||||||
|
|
@ -896,19 +888,11 @@ var CascadeStore = /** @class */ (function (_super) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// A中data的entityId作为B中filter的主键
|
// A中data的attrId作为B中filter的主键
|
||||||
Object.assign(operationMto_2, {
|
Object.assign(operationMto_2, {
|
||||||
filter: (0, filter_1.addFilterSegment)(filterMto || {}, {
|
filter: (0, filter_1.addFilterSegment)(filterMto || {}, (_d = {},
|
||||||
id: {
|
_d["".concat(entity, "$").concat(attr)] = filter,
|
||||||
$in: {
|
_d)),
|
||||||
entity: entity,
|
|
||||||
data: (_c = {},
|
|
||||||
_c["".concat(attr, "Id")] = 1,
|
|
||||||
_c),
|
|
||||||
filter: filter,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -916,7 +900,7 @@ var CascadeStore = /** @class */ (function (_super) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
(0, assert_1.default)(relation instanceof Array);
|
(0, assert_1.default)(relation instanceof Array);
|
||||||
var _g = tslib_1.__read(relation, 2), entityOtm_1 = _g[0], foreignKey_2 = _g[1];
|
var _h = tslib_1.__read(relation, 2), entityOtm_1 = _h[0], foreignKey_2 = _h[1];
|
||||||
var otmOperations = data[attr];
|
var otmOperations = data[attr];
|
||||||
var dealWithOneToMany = function (otm) {
|
var dealWithOneToMany = function (otm) {
|
||||||
var _a, _b, _c, _d, _e, _f;
|
var _a, _b, _c, _d, _e, _f;
|
||||||
|
|
@ -1067,7 +1051,7 @@ var CascadeStore = /** @class */ (function (_super) {
|
||||||
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
||||||
finally {
|
finally {
|
||||||
try {
|
try {
|
||||||
if (otmOperations_1_1 && !otmOperations_1_1.done && (_d = otmOperations_1.return)) _d.call(otmOperations_1);
|
if (otmOperations_1_1 && !otmOperations_1_1.done && (_e = otmOperations_1.return)) _e.call(otmOperations_1);
|
||||||
}
|
}
|
||||||
finally { if (e_2) throw e_2.error; }
|
finally { if (e_2) throw e_2.error; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1318,27 +1318,15 @@ var RelationAuth = /** @class */ (function () {
|
||||||
var userId = context.getCurrentUserId();
|
var userId = context.getCurrentUserId();
|
||||||
(0, assert_1.default)(filter);
|
(0, assert_1.default)(filter);
|
||||||
var contained = {
|
var contained = {
|
||||||
relationId: {
|
relation: {
|
||||||
$in: {
|
relationAuth$destRelation: {
|
||||||
entity: 'relationAuth',
|
sourceRelation: {
|
||||||
data: {
|
userRelation$relation: {
|
||||||
destRelationId: 1,
|
|
||||||
},
|
|
||||||
filter: {
|
|
||||||
sourceRelationId: {
|
|
||||||
$in: {
|
|
||||||
entity: 'userRelation',
|
|
||||||
data: {
|
|
||||||
relationId: 1,
|
|
||||||
},
|
|
||||||
filter: {
|
|
||||||
userId: userId,
|
userId: userId,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
return (0, filter_1.checkFilterContains)(entity2, context, contained, filter, true);
|
return (0, filter_1.checkFilterContains)(entity2, context, contained, filter, true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -969,17 +969,9 @@ export abstract class CascadeStore<ED extends EntityDict & BaseEntityDict> exten
|
||||||
// A中data的entityId作为B中filter的主键
|
// A中data的entityId作为B中filter的主键
|
||||||
Object.assign(operationMto, {
|
Object.assign(operationMto, {
|
||||||
filter: addFilterSegment({
|
filter: addFilterSegment({
|
||||||
id: {
|
[`${entity as string}$entity`]: {
|
||||||
$in: {
|
filter,
|
||||||
entity,
|
|
||||||
data: {
|
|
||||||
entityId: 1,
|
|
||||||
},
|
|
||||||
filter: addFilterSegment({
|
|
||||||
entity: attr,
|
|
||||||
} as any, filter),
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
}, filterMto),
|
}, filterMto),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -1034,18 +1026,10 @@ export abstract class CascadeStore<ED extends EntityDict & BaseEntityDict> exten
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// A中data的entityId作为B中filter的主键
|
// A中data的attrId作为B中filter的主键
|
||||||
Object.assign(operationMto, {
|
Object.assign(operationMto, {
|
||||||
filter: addFilterSegment(filterMto || {}, {
|
filter: addFilterSegment(filterMto || {}, {
|
||||||
id: {
|
[`${entity as string}$${attr}`]: filter
|
||||||
$in: {
|
|
||||||
entity,
|
|
||||||
data: {
|
|
||||||
[`${attr}Id`]: 1,
|
|
||||||
},
|
|
||||||
filter,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1551,28 +1551,16 @@ export class RelationAuth<ED extends EntityDict & BaseEntityDict>{
|
||||||
assert(action === 'remove');
|
assert(action === 'remove');
|
||||||
const userId = context.getCurrentUserId();
|
const userId = context.getCurrentUserId();
|
||||||
assert(filter);
|
assert(filter);
|
||||||
const contained = {
|
const contained: ED['userRelation']['Selection']['filter'] = {
|
||||||
relationId: {
|
relation: {
|
||||||
$in: {
|
relationAuth$destRelation: {
|
||||||
entity: 'relationAuth',
|
sourceRelation: {
|
||||||
data: {
|
userRelation$relation: {
|
||||||
destRelationId: 1,
|
|
||||||
},
|
|
||||||
filter: {
|
|
||||||
sourceRelationId: {
|
|
||||||
$in: {
|
|
||||||
entity: 'userRelation',
|
|
||||||
data: {
|
|
||||||
relationId: 1,
|
|
||||||
},
|
|
||||||
filter: {
|
|
||||||
userId,
|
userId,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
return checkFilterContains(entity2, context, contained, filter, true);
|
return checkFilterContains(entity2, context, contained, filter, true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue