在寻找查询条件的锚点时,所有可能的锚点都不能过滤
This commit is contained in:
parent
70dbf3b136
commit
fed8244396
|
|
@ -36,7 +36,6 @@ var RelationAuth = /** @class */ (function () {
|
|||
var findHighestAnchors = function (entity, filter, path, excludePaths) {
|
||||
var _a;
|
||||
var anchors = [];
|
||||
var anchorsOnMe = [];
|
||||
var _loop_1 = function (attr) {
|
||||
if (attr === '$and') {
|
||||
filter[attr].forEach(function (ele) { return anchors.push.apply(anchors, tslib_1.__spreadArray([], tslib_1.__read(findHighestAnchors(entity, ele, path, excludePaths)), false)); });
|
||||
|
|
@ -68,24 +67,13 @@ var RelationAuth = /** @class */ (function () {
|
|||
if (attr === 'entity' && (pathGroup[filter.entity] || filter.entity === 'user')) {
|
||||
var nextPath = path ? "".concat(path, ".").concat(filter.entity) : filter.entity;
|
||||
if (filter.entityId) {
|
||||
if (filter.entity === 'user') {
|
||||
anchors.push({
|
||||
entity: filter.entity,
|
||||
filter: {
|
||||
id: filter.entityId,
|
||||
},
|
||||
relativePath: nextPath,
|
||||
});
|
||||
}
|
||||
else {
|
||||
anchorsOnMe.push({
|
||||
entity: filter.entity,
|
||||
filter: {
|
||||
id: filter.entityId,
|
||||
},
|
||||
relativePath: nextPath,
|
||||
});
|
||||
}
|
||||
anchors.push({
|
||||
entity: filter.entity,
|
||||
filter: {
|
||||
id: filter.entityId,
|
||||
},
|
||||
relativePath: nextPath,
|
||||
});
|
||||
}
|
||||
var attributes = _this.schema[entity].attributes;
|
||||
var ref = attributes.entity.ref;
|
||||
|
|
@ -100,16 +88,7 @@ var RelationAuth = /** @class */ (function () {
|
|||
else if (((_a = _this.schema[entity].attributes[attr]) === null || _a === void 0 ? void 0 : _a.type) === 'ref') {
|
||||
var ref = _this.schema[entity].attributes[attr].ref;
|
||||
(0, assert_1.default)(typeof ref === 'string');
|
||||
if (pathGroup[ref]) {
|
||||
anchorsOnMe.push({
|
||||
entity: ref,
|
||||
filter: {
|
||||
id: filter[attr],
|
||||
},
|
||||
relativePath: path ? "".concat(path, ".").concat(attr.slice(0, attr.length - 2)) : attr.slice(0, attr.length - 2)
|
||||
});
|
||||
}
|
||||
else if (ref === 'user') {
|
||||
if (pathGroup[ref] || ref === 'user') {
|
||||
anchors.push({
|
||||
entity: ref,
|
||||
filter: {
|
||||
|
|
@ -127,9 +106,6 @@ var RelationAuth = /** @class */ (function () {
|
|||
if (anchors.length > 0) {
|
||||
return anchors;
|
||||
}
|
||||
if (anchorsOnMe.length > 0) {
|
||||
return anchorsOnMe;
|
||||
}
|
||||
if (filter.id) {
|
||||
// 直接以id作为查询目标
|
||||
return [{
|
||||
|
|
|
|||
|
|
@ -72,7 +72,6 @@ export class RelationAuth<ED extends EntityDict & BaseEntityDict>{
|
|||
|
||||
const findHighestAnchors = (entity: keyof ED, filter: NonNullable<ED[keyof ED]['Selection']['filter']>, path: string, excludePaths: string[]): Anchor[] => {
|
||||
const anchors = [] as Anchor[];
|
||||
const anchorsOnMe = [] as Anchor[];
|
||||
for (const attr in filter) {
|
||||
if (attr === '$and') {
|
||||
filter[attr].forEach(
|
||||
|
|
@ -110,24 +109,13 @@ export class RelationAuth<ED extends EntityDict & BaseEntityDict>{
|
|||
if (attr === 'entity' && (pathGroup[filter.entity] || filter.entity === 'user')) {
|
||||
const nextPath = path ? `${path}.${filter.entity as string}` : filter.entity;
|
||||
if (filter.entityId) {
|
||||
if (filter.entity === 'user') {
|
||||
anchors.push({
|
||||
entity: filter.entity,
|
||||
filter: {
|
||||
id: filter.entityId,
|
||||
},
|
||||
relativePath: nextPath,
|
||||
});
|
||||
}
|
||||
else {
|
||||
anchorsOnMe.push({
|
||||
entity: filter.entity,
|
||||
filter: {
|
||||
id: filter.entityId,
|
||||
},
|
||||
relativePath: nextPath,
|
||||
});
|
||||
}
|
||||
anchors.push({
|
||||
entity: filter.entity,
|
||||
filter: {
|
||||
id: filter.entityId,
|
||||
},
|
||||
relativePath: nextPath,
|
||||
});
|
||||
}
|
||||
const { attributes } = this.schema[entity];
|
||||
const { ref } = attributes.entity;
|
||||
|
|
@ -144,16 +132,7 @@ export class RelationAuth<ED extends EntityDict & BaseEntityDict>{
|
|||
else if (this.schema[entity].attributes[attr as any]?.type === 'ref') {
|
||||
const { ref } = this.schema[entity].attributes[attr as any];
|
||||
assert(typeof ref === 'string');
|
||||
if (pathGroup[ref]) {
|
||||
anchorsOnMe.push({
|
||||
entity: ref,
|
||||
filter: {
|
||||
id: filter[attr],
|
||||
},
|
||||
relativePath: path ? `${path}.${attr.slice(0, attr.length - 2)}` : attr.slice(0, attr.length - 2)
|
||||
});
|
||||
}
|
||||
else if (ref === 'user') {
|
||||
if (pathGroup[ref] || ref === 'user') {
|
||||
anchors.push({
|
||||
entity: ref,
|
||||
filter: {
|
||||
|
|
@ -168,9 +147,6 @@ export class RelationAuth<ED extends EntityDict & BaseEntityDict>{
|
|||
if (anchors.length > 0) {
|
||||
return anchors;
|
||||
}
|
||||
if (anchorsOnMe.length > 0) {
|
||||
return anchorsOnMe;
|
||||
}
|
||||
if (filter.id) {
|
||||
// 直接以id作为查询目标
|
||||
return [{
|
||||
|
|
|
|||
Loading…
Reference in New Issue