From 05aa27af836242379534f12712d3dd9e911deee8 Mon Sep 17 00:00:00 2001 From: "Xc@centOs" Date: Mon, 24 Jul 2023 15:30:01 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=94=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/store/RelationAuth.js | 8 +++----- src/store/RelationAuth.ts | 9 +++------ 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/store/RelationAuth.js b/lib/store/RelationAuth.js index 66d80cb..a4873ac 100644 --- a/lib/store/RelationAuth.js +++ b/lib/store/RelationAuth.js @@ -1487,9 +1487,6 @@ var RelationAuth = /** @class */ (function () { } return filter; }; - var action = operation2.action, data = operation2.data, filter = operation2.filter; - var filter2 = action === 'create' ? makeCreateFilter(operation2) : filter; - (0, assert_1.default)(filter2); var addChild = function (node, path, child) { var _a; if (node.children[path]) { @@ -1508,7 +1505,7 @@ var RelationAuth = /** @class */ (function () { }; var destructInner = function (entity, operation, path, child, hasParent) { var action = operation.action, data = operation.data, filter = operation.filter; - var filter2 = action === 'create' ? data || filter : filter; + var filter2 = action === 'create' ? makeCreateFilter(operation) : filter; (0, assert_1.default)(filter2); var me = { entity: entity, @@ -1593,9 +1590,10 @@ var RelationAuth = /** @class */ (function () { if (userRelations.length > 0) { var entityIds = (0, lodash_1.uniq)(userRelations.map(function (ele) { return ele.entityId; })); var contained_1 = {}; - var idFilter = entityIds.length > 0 ? { + var idFilter = entityIds.length > 1 ? { $in: entityIds, } : entityIds[0]; + (0, assert_1.default)(idFilter); if (path) { (0, lodash_1.set)(contained_1, path, { id: idFilter, diff --git a/src/store/RelationAuth.ts b/src/store/RelationAuth.ts index 8912f29..2d7a099 100644 --- a/src/store/RelationAuth.ts +++ b/src/store/RelationAuth.ts @@ -1736,10 +1736,6 @@ export class RelationAuth{ return filter; }; - const { action, data, filter } = operation2; - const filter2 = action === 'create' ? makeCreateFilter(operation2 as Omit) : filter; - assert(filter2); - const addChild = (node: OperationTree, path: string, child: OperationTree) => { if (node.children[path]) { if (node.children[path] instanceof Array) { @@ -1758,7 +1754,7 @@ export class RelationAuth{ const destructInner = (entity: T2, operation: Omit, path?: string, child?: OperationTree, hasParent?: true): OperationTree => { const { action, data, filter } = operation; - const filter2 = action === 'create' ? data || filter : filter; + const filter2 = action === 'create' ? makeCreateFilter(operation as Omit) : filter; assert(filter2); const me: OperationTree = { @@ -1860,9 +1856,10 @@ export class RelationAuth{ if (userRelations!.length > 0) { const entityIds = uniq(userRelations!.map(ele => ele.entityId)); const contained = {}; - const idFilter = entityIds.length > 0 ? { + const idFilter = entityIds.length > 1 ? { $in: entityIds, } : entityIds[0]; + assert(idFilter); if (path) { set(contained, path, { id: idFilter,