在分解cascade更新时,对create的数据进行精细化处理
This commit is contained in:
parent
a31619efa8
commit
6e8cd9e3ec
|
|
@ -1467,8 +1467,28 @@ var RelationAuth = /** @class */ (function () {
|
|||
*/
|
||||
RelationAuth.prototype.destructOperation = function (entity2, operation2, userId) {
|
||||
var _this = this;
|
||||
/**
|
||||
* 对create动作,把data中的cascade部分剔除后作为filter参与后续的检验
|
||||
* @param operation
|
||||
* @returns
|
||||
*/
|
||||
var makeCreateFilter = function (operation) {
|
||||
var data = operation.data, filter = operation.filter;
|
||||
(0, assert_1.default)(!(data instanceof Array));
|
||||
if (data) {
|
||||
var data2 = {};
|
||||
for (var attr in data) {
|
||||
var rel = (0, relation_1.judgeRelation)(_this.schema, entity2, attr);
|
||||
if (rel === 1) {
|
||||
data2[attr] = data[attr];
|
||||
}
|
||||
}
|
||||
return data2;
|
||||
}
|
||||
return filter;
|
||||
};
|
||||
var action = operation2.action, data = operation2.data, filter = operation2.filter;
|
||||
var filter2 = action === 'create' ? data || filter : filter;
|
||||
var filter2 = action === 'create' ? makeCreateFilter(operation2) : filter;
|
||||
(0, assert_1.default)(filter2);
|
||||
var addChild = function (node, path, child) {
|
||||
var _a;
|
||||
|
|
|
|||
|
|
@ -1714,9 +1714,30 @@ export class RelationAuth<ED extends EntityDict & BaseEntityDict>{
|
|||
* @param entity
|
||||
* @param selection
|
||||
*/
|
||||
private destructOperation<T extends keyof ED>(entity2: T, operation2: Omit<ED[T]['Operation'], 'id'>, userId: string) {
|
||||
private destructOperation<T extends keyof ED>(entity2: T, operation2: Omit<ED[T]['Operation'], 'id'>, userId: string) {
|
||||
/**
|
||||
* 对create动作,把data中的cascade部分剔除后作为filter参与后续的检验
|
||||
* @param operation
|
||||
* @returns
|
||||
*/
|
||||
const makeCreateFilter = (operation: Omit<ED[T]['CreateSingle'], 'id'>) => {
|
||||
const { data, filter } = operation;
|
||||
assert(!(data instanceof Array));
|
||||
if (data) {
|
||||
const data2: ED[T]['Selection']['filter'] = {};
|
||||
for (const attr in data) {
|
||||
const rel = judgeRelation(this.schema, entity2, attr);
|
||||
if (rel === 1) {
|
||||
data2[attr] = data[attr];
|
||||
}
|
||||
}
|
||||
return data2;
|
||||
}
|
||||
return filter;
|
||||
};
|
||||
|
||||
const { action, data, filter } = operation2;
|
||||
const filter2 = action === 'create' ? data || filter : filter;
|
||||
const filter2 = action === 'create' ? makeCreateFilter(operation2 as Omit<ED[T]['CreateSingle'], 'id'>) : filter;
|
||||
assert(filter2);
|
||||
|
||||
const addChild = (node: OperationTree<ED>, path: string, child: OperationTree<ED>) => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue