在构建contained filter时,处理了path为空的情况

This commit is contained in:
Xu Chang 2023-07-24 14:33:03 +08:00
parent 79dc2cfdbb
commit a31619efa8
2 changed files with 29 additions and 13 deletions

View File

@ -1571,13 +1571,21 @@ var RelationAuth = /** @class */ (function () {
(0, assert_1.default)(relation);
var userRelations = relation.userRelation$relation;
if (userRelations.length > 0) {
var entityIds = userRelations.map(function (ele) { return ele.entityId; });
var entityIds = (0, lodash_1.uniq)(userRelations.map(function (ele) { return ele.entityId; }));
var contained_1 = {};
(0, lodash_1.set)(contained_1, path, {
id: {
$in: entityIds,
}
});
var idFilter = entityIds.length > 0 ? {
$in: entityIds,
} : entityIds[0];
if (path) {
(0, lodash_1.set)(contained_1, path, {
id: idFilter,
});
}
else {
Object.assign(contained_1, {
id: idFilter
});
}
var contains = (0, filter_1.checkFilterContains)(entity, context, contained_1, filter, true);
if (contains instanceof Promise) {
return contains.then(function (c) {

View File

@ -7,7 +7,7 @@ import { addFilterSegment, checkFilterContains, combineFilters } from "./filter"
import { judgeRelation } from "./relation";
import { SyncContext } from "./SyncRowStore";
import { readOnlyActions } from '../actions/action';
import { difference, intersection, set } from '../utils/lodash';
import { difference, intersection, set, uniq } from '../utils/lodash';
import { SYSTEM_RESERVE_ENTITIES } from "../compiler/env";
@ -1837,13 +1837,21 @@ export class RelationAuth<ED extends EntityDict & BaseEntityDict>{
assert(relation);
const { userRelation$relation: userRelations } = relation;
if (userRelations!.length > 0) {
const entityIds = userRelations!.map(ele => ele.entityId);
const entityIds = uniq(userRelations!.map(ele => ele.entityId));
const contained = {};
set(contained, path, {
id: {
$in: entityIds,
}
});
const idFilter = entityIds.length > 0 ? {
$in: entityIds,
} : entityIds[0];
if (path) {
set(contained, path, {
id: idFilter,
});
}
else {
Object.assign(contained, {
id: idFilter
});
}
const contains = checkFilterContains(entity, context, contained, filter, true)
if (contains instanceof Promise) {
return contains.then(