@ruiapp/rapid-core 0.10.5 → 0.10.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +8 -8
- package/package.json +1 -1
- package/src/dataAccess/entityManager.ts +9 -14
package/dist/index.js
CHANGED
|
@@ -2600,8 +2600,8 @@ async function findEntities(server, dataAccessor, options) {
|
|
|
2600
2600
|
}
|
|
2601
2601
|
}
|
|
2602
2602
|
});
|
|
2603
|
-
// if `keepNonPropertyFields` is true
|
|
2604
|
-
if (options.keepNonPropertyFields
|
|
2603
|
+
// if `keepNonPropertyFields` is true, then select relation columns automatically.
|
|
2604
|
+
if (options.keepNonPropertyFields) {
|
|
2605
2605
|
const oneRelationPropertiesWithNoLinkTable = getEntityPropertiesIncludingBase(server, model).filter((property) => property.relation === "one" && !property.linkTableName);
|
|
2606
2606
|
oneRelationPropertiesWithNoLinkTable.forEach((property) => {
|
|
2607
2607
|
if (property.targetIdColumnName) {
|
|
@@ -2675,12 +2675,12 @@ async function findEntities(server, dataAccessor, options) {
|
|
|
2675
2675
|
return lodash.find(relationLinks, (link) => {
|
|
2676
2676
|
return link[relationProperty.selfIdColumnName] == row["id"] && link[relationProperty.targetIdColumnName] == targetEntity["id"];
|
|
2677
2677
|
});
|
|
2678
|
-
})
|
|
2678
|
+
});
|
|
2679
2679
|
}
|
|
2680
2680
|
else {
|
|
2681
2681
|
row[relationProperty.code] = lodash.filter(relationLinks, (link) => {
|
|
2682
2682
|
return link[relationProperty.selfIdColumnName] == row["id"];
|
|
2683
|
-
}).map((link) =>
|
|
2683
|
+
}).map((link) => link.targetEntity);
|
|
2684
2684
|
}
|
|
2685
2685
|
});
|
|
2686
2686
|
}
|
|
@@ -2708,20 +2708,20 @@ async function findEntities(server, dataAccessor, options) {
|
|
|
2708
2708
|
selectRelationOptions: relationOptions[relationProperty.code],
|
|
2709
2709
|
});
|
|
2710
2710
|
}
|
|
2711
|
-
|
|
2711
|
+
server.getModel({
|
|
2712
2712
|
singularCode: relationProperty.targetSingularCode,
|
|
2713
2713
|
});
|
|
2714
2714
|
rows.forEach((row) => {
|
|
2715
2715
|
if (isManyRelation) {
|
|
2716
2716
|
row[relationProperty.code] = lodash.filter(relatedEntities, (relatedEntity) => {
|
|
2717
2717
|
return relatedEntity[relationProperty.selfIdColumnName] == row.id;
|
|
2718
|
-
})
|
|
2718
|
+
});
|
|
2719
2719
|
}
|
|
2720
2720
|
else {
|
|
2721
|
-
row[relationProperty.code] =
|
|
2721
|
+
row[relationProperty.code] = lodash.find(relatedEntities, (relatedEntity) => {
|
|
2722
2722
|
// TODO: id property code should be configurable.
|
|
2723
2723
|
return relatedEntity["id"] == row[relationProperty.targetIdColumnName];
|
|
2724
|
-
})
|
|
2724
|
+
});
|
|
2725
2725
|
}
|
|
2726
2726
|
});
|
|
2727
2727
|
}
|
package/package.json
CHANGED
|
@@ -208,8 +208,8 @@ async function findEntities(server: IRpdServer, dataAccessor: IRpdDataAccessor,
|
|
|
208
208
|
}
|
|
209
209
|
});
|
|
210
210
|
|
|
211
|
-
// if `keepNonPropertyFields` is true
|
|
212
|
-
if (options.keepNonPropertyFields
|
|
211
|
+
// if `keepNonPropertyFields` is true, then select relation columns automatically.
|
|
212
|
+
if (options.keepNonPropertyFields) {
|
|
213
213
|
const oneRelationPropertiesWithNoLinkTable = getEntityPropertiesIncludingBase(server, model).filter(
|
|
214
214
|
(property) => property.relation === "one" && !property.linkTableName,
|
|
215
215
|
);
|
|
@@ -289,11 +289,11 @@ async function findEntities(server: IRpdServer, dataAccessor: IRpdDataAccessor,
|
|
|
289
289
|
return find(relationLinks, (link: any) => {
|
|
290
290
|
return link[relationProperty.selfIdColumnName!] == row["id"] && link[relationProperty.targetIdColumnName!] == targetEntity["id"];
|
|
291
291
|
});
|
|
292
|
-
})
|
|
292
|
+
});
|
|
293
293
|
} else {
|
|
294
294
|
row[relationProperty.code] = filter(relationLinks, (link: any) => {
|
|
295
295
|
return link[relationProperty.selfIdColumnName!] == row["id"];
|
|
296
|
-
}).map((link) =>
|
|
296
|
+
}).map((link) => link.targetEntity);
|
|
297
297
|
}
|
|
298
298
|
});
|
|
299
299
|
}
|
|
@@ -332,17 +332,12 @@ async function findEntities(server: IRpdServer, dataAccessor: IRpdDataAccessor,
|
|
|
332
332
|
if (isManyRelation) {
|
|
333
333
|
row[relationProperty.code] = filter(relatedEntities, (relatedEntity: any) => {
|
|
334
334
|
return relatedEntity[relationProperty.selfIdColumnName!] == row.id;
|
|
335
|
-
})
|
|
335
|
+
});
|
|
336
336
|
} else {
|
|
337
|
-
row[relationProperty.code] =
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
// TODO: id property code should be configurable.
|
|
342
|
-
return relatedEntity["id"] == row[relationProperty.targetIdColumnName!];
|
|
343
|
-
}),
|
|
344
|
-
options.keepNonPropertyFields,
|
|
345
|
-
);
|
|
337
|
+
row[relationProperty.code] = find(relatedEntities, (relatedEntity: any) => {
|
|
338
|
+
// TODO: id property code should be configurable.
|
|
339
|
+
return relatedEntity["id"] == row[relationProperty.targetIdColumnName!];
|
|
340
|
+
});
|
|
346
341
|
}
|
|
347
342
|
});
|
|
348
343
|
}
|