law-common 10.30.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.
|
@@ -15,11 +15,11 @@ class BaseEntityModel {
|
|
|
15
15
|
const thisMappingKey = relationConfig.mapKeyConfig.key;
|
|
16
16
|
const relatedMappingKey = relationConfig.mapKeyConfig.relationKey;
|
|
17
17
|
const thisKey = relationConfig.key;
|
|
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,16 +33,20 @@ 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]]] : [];
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
// console.log(
|
|
41
|
+
// `[populateRelationsByIndex] Looking for relation "${relationConfig.name}" on entity "${this.entityName}" where relatedEntities[${this[thisMappingKey]}]`
|
|
42
|
+
// );
|
|
43
|
+
if (relatedMappingKey === "id") {
|
|
44
|
+
const relatedEntity = relatedEntitiesIndex[this[thisMappingKey]];
|
|
42
45
|
foundRelatedEntities = [relatedEntity];
|
|
43
46
|
}
|
|
44
47
|
else if (relatedMappingKey !== "id") {
|
|
45
|
-
|
|
48
|
+
console.log(`[populateRelationsByIndex] Searching through related entities for relation "${relationConfig.name}" on entity "${this.entityName}"`);
|
|
49
|
+
foundRelatedEntities = Object.values(relatedEntitiesIndex).filter((entity) => entity[relatedMappingKey] === this[thisMappingKey]);
|
|
46
50
|
}
|
|
47
51
|
else {
|
|
48
52
|
foundRelatedEntities = [];
|
package/package.json
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "law-common",
|
|
3
|
-
"version": "10.30.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"files": [
|
|
7
|
-
"dist/**/*"
|
|
8
|
-
],
|
|
9
|
-
"scripts": {
|
|
10
|
-
"clean": "rm -rf dist",
|
|
11
|
-
"build": "npm run clean && tsc",
|
|
12
|
-
"publish:beta": "npm version prerelease --preid beta && git push && npm run build && npm publish --tag beta",
|
|
13
|
-
"publish:patch": "npm version patch && git push && npm run build && npm publish",
|
|
14
|
-
"publish:minor": "npm version minor && git push && npm run build && npm publish",
|
|
15
|
-
"publish:major": "npm version major && git push && npm run build && npm publish",
|
|
16
|
-
"link": "npm run build && npm link",
|
|
17
|
-
"test": "jest"
|
|
18
|
-
},
|
|
19
|
-
"keywords": [],
|
|
20
|
-
"author": "",
|
|
21
|
-
"license": "ISC",
|
|
22
|
-
"devDependencies": {
|
|
23
|
-
"@types/jest": "^29.5.13",
|
|
24
|
-
"@types/node": "^22.6.1",
|
|
25
|
-
"jest": "^29.7.0",
|
|
26
|
-
"ts-jest": "^29.2.5",
|
|
27
|
-
"ts-node": "^10.9.2",
|
|
28
|
-
"typescript": "^5.6.2"
|
|
29
|
-
},
|
|
30
|
-
"dependencies": {
|
|
31
|
-
"@types/express": "^5.0.0",
|
|
32
|
-
"@types/multer": "^1.4.12",
|
|
33
|
-
"date-fns": "^4.1.0"
|
|
34
|
-
}
|
|
35
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "law-common",
|
|
3
|
+
"version": "10.30.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist/**/*"
|
|
8
|
+
],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"clean": "rm -rf dist",
|
|
11
|
+
"build": "npm run clean && tsc",
|
|
12
|
+
"publish:beta": "npm version prerelease --preid beta && git push && npm run build && npm publish --tag beta",
|
|
13
|
+
"publish:patch": "npm version patch && git push && npm run build && npm publish",
|
|
14
|
+
"publish:minor": "npm version minor && git push && npm run build && npm publish",
|
|
15
|
+
"publish:major": "npm version major && git push && npm run build && npm publish",
|
|
16
|
+
"link": "npm run build && npm link",
|
|
17
|
+
"test": "jest"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [],
|
|
20
|
+
"author": "",
|
|
21
|
+
"license": "ISC",
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/jest": "^29.5.13",
|
|
24
|
+
"@types/node": "^22.6.1",
|
|
25
|
+
"jest": "^29.7.0",
|
|
26
|
+
"ts-jest": "^29.2.5",
|
|
27
|
+
"ts-node": "^10.9.2",
|
|
28
|
+
"typescript": "^5.6.2"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@types/express": "^5.0.0",
|
|
32
|
+
"@types/multer": "^1.4.12",
|
|
33
|
+
"date-fns": "^4.1.0"
|
|
34
|
+
}
|
|
35
|
+
}
|