优化了cascadeSelect结果,返回时剪除掉不必要的分支
This commit is contained in:
parent
d639aa9281
commit
41ed11639e
|
|
@ -37,8 +37,11 @@ function buildResultTree(schema, entity, result) {
|
|||
else if (typeof r[attr] === 'object') {
|
||||
const rel = judgeRelation(schema, e, attr);
|
||||
if (rel === 2 || typeof rel === 'string') {
|
||||
tree[attr] = {};
|
||||
pruneInner(rel === 2 ? attr : rel, r[attr], tree[attr]);
|
||||
const son = {};
|
||||
pruneInner(rel === 2 ? attr : rel, r[attr], son);
|
||||
if (Object.keys(son).length > 0) {
|
||||
tree[attr] = son;
|
||||
}
|
||||
}
|
||||
else if (rel instanceof Array) {
|
||||
assert(r[attr] instanceof Array);
|
||||
|
|
|
|||
|
|
@ -41,8 +41,11 @@ function buildResultTree(schema, entity, result) {
|
|||
else if (typeof r[attr] === 'object') {
|
||||
const rel = (0, relation_1.judgeRelation)(schema, e, attr);
|
||||
if (rel === 2 || typeof rel === 'string') {
|
||||
tree[attr] = {};
|
||||
pruneInner(rel === 2 ? attr : rel, r[attr], tree[attr]);
|
||||
const son = {};
|
||||
pruneInner(rel === 2 ? attr : rel, r[attr], son);
|
||||
if (Object.keys(son).length > 0) {
|
||||
tree[attr] = son;
|
||||
}
|
||||
}
|
||||
else if (rel instanceof Array) {
|
||||
(0, assert_1.assert)(r[attr] instanceof Array);
|
||||
|
|
|
|||
|
|
@ -73,8 +73,11 @@ function buildResultTree<ED extends BaseEntityDict & EntityDict, T extends keyof
|
|||
else if (typeof r[attr] === 'object') {
|
||||
const rel = judgeRelation(schema, e, attr);
|
||||
if (rel === 2 || typeof rel === 'string') {
|
||||
tree[attr] = {};
|
||||
pruneInner(rel === 2 ? attr : rel, r[attr]!, tree[attr]);
|
||||
const son = {}
|
||||
pruneInner(rel === 2 ? attr : rel, r[attr]!, son);
|
||||
if (Object.keys(son).length > 0) {
|
||||
tree[attr] = son;
|
||||
}
|
||||
}
|
||||
else if (rel instanceof Array) {
|
||||
assert(r[attr] as any instanceof Array);
|
||||
|
|
|
|||
Loading…
Reference in New Issue