This commit is contained in:
Xu Chang 2023-07-24 15:30:01 +08:00
parent 6e8cd9e3ec
commit 05aa27af83
2 changed files with 6 additions and 11 deletions

View File

@ -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,

View File

@ -1736,10 +1736,6 @@ export class RelationAuth<ED extends EntityDict & BaseEntityDict>{
return filter;
};
const { action, data, filter } = operation2;
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>) => {
if (node.children[path]) {
if (node.children[path] instanceof Array) {
@ -1758,7 +1754,7 @@ export class RelationAuth<ED extends EntityDict & BaseEntityDict>{
const destructInner = <T2 extends keyof ED>(entity: T2, operation: Omit<ED[T2]['Operation'], 'id'>, path?: string, child?: OperationTree<ED>, hasParent?: true): OperationTree<ED> => {
const { action, data, filter } = operation;
const filter2 = action === 'create' ? data || filter : filter;
const filter2 = action === 'create' ? makeCreateFilter(operation as Omit<ED[T]['CreateSingle'], 'id'>) : filter;
assert(filter2);
const me: OperationTree<ED> = {
@ -1860,9 +1856,10 @@ export class RelationAuth<ED extends EntityDict & BaseEntityDict>{
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,