@technicity/data-service-generator 0.19.1 → 0.20.0
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/generation/generate.js +16 -8
- package/package.json +1 -1
|
@@ -1445,9 +1445,12 @@ const getRelationInfo = _.memoize(async function getRelationInfo(table) {
|
|
|
1445
1445
|
const relationsManyToOne = await getRelationsManyToOne(table);
|
|
1446
1446
|
const relationsOneToMany = await getRelationsOneToMany(table);
|
|
1447
1447
|
let out = [];
|
|
1448
|
-
out = out.concat(relationsManyToOne.
|
|
1448
|
+
out = out.concat(relationsManyToOne.reduce((acc, x) => {
|
|
1449
|
+
if (!x.foreignKey.endsWith("Id")) {
|
|
1450
|
+
return acc;
|
|
1451
|
+
}
|
|
1449
1452
|
const name = getRelationManyToOneFieldName(x);
|
|
1450
|
-
|
|
1453
|
+
acc.push({
|
|
1451
1454
|
type: "one-to-many__many-to-one",
|
|
1452
1455
|
kind: "many-to-one",
|
|
1453
1456
|
grabMany: false,
|
|
@@ -1455,10 +1458,14 @@ const getRelationInfo = _.memoize(async function getRelationInfo(table) {
|
|
|
1455
1458
|
name,
|
|
1456
1459
|
relation: x,
|
|
1457
1460
|
nullable: x.nullable
|
|
1458
|
-
};
|
|
1459
|
-
|
|
1461
|
+
});
|
|
1462
|
+
return acc;
|
|
1463
|
+
}, []));
|
|
1460
1464
|
const relationsOneToManyDuplicates = (0, getDuplicates_1.getDuplicates)(relationsOneToMany.map((x) => x.referencedTable));
|
|
1461
|
-
out = out.concat(relationsOneToMany.
|
|
1465
|
+
out = out.concat(relationsOneToMany.reduce((acc, x) => {
|
|
1466
|
+
if (!x.referencedKey.endsWith("Id")) {
|
|
1467
|
+
return acc;
|
|
1468
|
+
}
|
|
1462
1469
|
let name = changeCase.camelCase(x.referencedTable) + "List";
|
|
1463
1470
|
if (relationsOneToManyDuplicates.includes(x.referencedTable)) {
|
|
1464
1471
|
// Examples:
|
|
@@ -1470,7 +1477,7 @@ const getRelationInfo = _.memoize(async function getRelationInfo(table) {
|
|
|
1470
1477
|
changeCase.pascalCase(x.referencedKey.replace(new RegExp(x.foreignKey + "$", "i"), "")) +
|
|
1471
1478
|
"List";
|
|
1472
1479
|
}
|
|
1473
|
-
|
|
1480
|
+
acc.push({
|
|
1474
1481
|
type: "one-to-many__many-to-one",
|
|
1475
1482
|
kind: "one-to-many",
|
|
1476
1483
|
grabMany: true,
|
|
@@ -1478,8 +1485,9 @@ const getRelationInfo = _.memoize(async function getRelationInfo(table) {
|
|
|
1478
1485
|
name,
|
|
1479
1486
|
relation: x,
|
|
1480
1487
|
nullable: x.nullable
|
|
1481
|
-
};
|
|
1482
|
-
|
|
1488
|
+
});
|
|
1489
|
+
return acc;
|
|
1490
|
+
}, []));
|
|
1483
1491
|
const relationsManyToMany = (await getJunctionTables()).reduce((acc, x) => {
|
|
1484
1492
|
const dataForParentTable = x.relations.find((r) => r.referencedTable === table);
|
|
1485
1493
|
if (dataForParentTable == null) {
|