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