law-common 10.30.1-beta.0 → 10.30.1
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.
|
@@ -18,8 +18,8 @@ class BaseEntityModel {
|
|
|
18
18
|
console.log('Populating relation for', relationConfig.name, 'on', this.entityName, relationConfig);
|
|
19
19
|
// debugger;
|
|
20
20
|
if (relationConfig.relation === RelationType.ONE) {
|
|
21
|
-
const
|
|
22
|
-
if (Object.is(
|
|
21
|
+
const relatedEntitiesIndex = entityIndexMap[relationConfig.name] || {};
|
|
22
|
+
if (Object.is(relatedEntitiesIndex, null))
|
|
23
23
|
continue;
|
|
24
24
|
let foundRelatedEntities = [];
|
|
25
25
|
if (thisMappingKey.includes(".")) {
|
|
@@ -33,7 +33,7 @@ class BaseEntityModel {
|
|
|
33
33
|
console.warn(`[populateRelationsByIndex] Missing child key "${childKey}" in parent "${parentKey}" on entity "${this.entityName}". Parent value:`, this[parentKey]);
|
|
34
34
|
continue;
|
|
35
35
|
}
|
|
36
|
-
foundRelatedEntities = [
|
|
36
|
+
foundRelatedEntities = [relatedEntitiesIndex[this[parentKey][childKey]]];
|
|
37
37
|
}
|
|
38
38
|
else {
|
|
39
39
|
// foundRelatedEntities = relatedEntities[this[thisKey]] ? [relatedEntities[this[thisKey]]] : [];
|
|
@@ -41,12 +41,12 @@ class BaseEntityModel {
|
|
|
41
41
|
// `[populateRelationsByIndex] Looking for relation "${relationConfig.name}" on entity "${this.entityName}" where relatedEntities[${this[thisMappingKey]}]`
|
|
42
42
|
// );
|
|
43
43
|
if (relatedMappingKey === "id") {
|
|
44
|
-
const relatedEntity =
|
|
44
|
+
const relatedEntity = relatedEntitiesIndex[this[thisMappingKey]];
|
|
45
45
|
foundRelatedEntities = [relatedEntity];
|
|
46
46
|
}
|
|
47
47
|
else if (relatedMappingKey !== "id") {
|
|
48
48
|
console.log(`[populateRelationsByIndex] Searching through related entities for relation "${relationConfig.name}" on entity "${this.entityName}"`);
|
|
49
|
-
foundRelatedEntities = Object.values(
|
|
49
|
+
foundRelatedEntities = Object.values(relatedEntitiesIndex).filter((entity) => entity[relatedMappingKey] === this[thisMappingKey]);
|
|
50
50
|
}
|
|
51
51
|
else {
|
|
52
52
|
foundRelatedEntities = [];
|