@loopback/repository 2.8.0 → 2.9.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/CHANGELOG.md +12 -0
- package/dist/relations/has-many/has-many-through-repository.factory.d.ts +2 -2
- package/dist/relations/has-many/has-many-through-repository.factory.js +12 -13
- package/dist/relations/has-many/has-many-through-repository.factory.js.map +1 -1
- package/dist/relations/has-many/has-many-through.helpers.d.ts +58 -17
- package/dist/relations/has-many/has-many-through.helpers.js +77 -32
- package/dist/relations/has-many/has-many-through.helpers.js.map +1 -1
- package/dist/relations/has-many/has-many-through.repository.d.ts +9 -8
- package/dist/relations/has-many/has-many-through.repository.js +32 -26
- package/dist/relations/has-many/has-many-through.repository.js.map +1 -1
- package/dist/repositories/legacy-juggler-bridge.d.ts +32 -1
- package/dist/repositories/legacy-juggler-bridge.js +34 -0
- package/dist/repositories/legacy-juggler-bridge.js.map +1 -1
- package/package.json +7 -7
- package/src/relations/has-many/has-many-through-repository.factory.ts +33 -26
- package/src/relations/has-many/has-many-through.helpers.ts +99 -36
- package/src/relations/has-many/has-many-through.repository.ts +50 -36
- package/src/repositories/legacy-juggler-bridge.ts +58 -0
|
@@ -181,6 +181,40 @@ class DefaultCrudRepository {
|
|
|
181
181
|
const meta = this.entityClass.definition.relations[relationName];
|
|
182
182
|
return relations_1.createHasManyRepositoryFactory(meta, targetRepoGetter);
|
|
183
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* Function to create a constrained hasManyThrough relation repository factory
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```ts
|
|
189
|
+
* class CustomerRepository extends DefaultCrudRepository<
|
|
190
|
+
* Customer,
|
|
191
|
+
* typeof Customer.prototype.id,
|
|
192
|
+
* CustomerRelations
|
|
193
|
+
* > {
|
|
194
|
+
* public readonly cartItems: HasManyRepositoryFactory<CartItem, typeof Customer.prototype.id>;
|
|
195
|
+
*
|
|
196
|
+
* constructor(
|
|
197
|
+
* protected db: juggler.DataSource,
|
|
198
|
+
* cartItemRepository: EntityCrudRepository<CartItem, typeof, CartItem.prototype.id>,
|
|
199
|
+
* throughRepository: EntityCrudRepository<Through, typeof Through.prototype.id>,
|
|
200
|
+
* ) {
|
|
201
|
+
* super(Customer, db);
|
|
202
|
+
* this.cartItems = this.createHasManyThroughRepositoryFactoryFor(
|
|
203
|
+
* 'cartItems',
|
|
204
|
+
* cartItemRepository,
|
|
205
|
+
* );
|
|
206
|
+
* }
|
|
207
|
+
* }
|
|
208
|
+
* ```
|
|
209
|
+
*
|
|
210
|
+
* @param relationName - Name of the relation defined on the source model
|
|
211
|
+
* @param targetRepo - Target repository instance
|
|
212
|
+
* @param throughRepo - Through repository instance
|
|
213
|
+
*/
|
|
214
|
+
createHasManyThroughRepositoryFactoryFor(relationName, targetRepoGetter, throughRepoGetter) {
|
|
215
|
+
const meta = this.entityClass.definition.relations[relationName];
|
|
216
|
+
return relations_1.createHasManyThroughRepositoryFactory(meta, targetRepoGetter, throughRepoGetter);
|
|
217
|
+
}
|
|
184
218
|
/**
|
|
185
219
|
* @deprecated
|
|
186
220
|
* Function to create a belongs to accessor
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"legacy-juggler-bridge.js","sourceRoot":"","sources":["../../src/repositories/legacy-juggler-bridge.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;;AAGhE,4DAA4B;AAC5B,sGAAiD;AAWjD,sCAA8C;AAC9C,oCAKkB;AAElB,4CAYsB;AAEtB,oDAA6D;AAM7D,IAAiB,OAAO,CAYvB;AAZD,WAAiB,OAAO;IACtB,sDAAsD;IACxC,kBAAU,GAAG,qCAAM,CAAC,UAAU,CAAC;IAC/B,iBAAS,GAAG,qCAAM,CAAC,SAAS,CAAC;IAE7B,sBAAc,GAAG,qCAAM,CAAC,cAAc,CAAC;IACvC,qBAAa,GAAG,qCAAM,CAAC,aAAa,CAAC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2
2
|
"name": "@loopback/repository",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
4
4
|
"description": "Define and implement a common set of interfaces for interacting with databases",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -22,17 +22,17 @@
|
|
|
22
22
|
"access": "public"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@loopback/build": "^6.
|
|
26
|
-
"@loopback/eslint-config": "^8.0.
|
|
27
|
-
"@loopback/testlab": "^3.
|
|
25
|
+
"@loopback/build": "^6.1.0",
|
|
26
|
+
"@loopback/eslint-config": "^8.0.3",
|
|
27
|
+
"@loopback/testlab": "^3.2.0",
|
|
28
28
|
"@types/bson": "^4.0.2",
|
|
29
29
|
"@types/json-schema": "^7.0.5",
|
|
30
|
-
"@types/lodash": "^4.14.
|
|
30
|
+
"@types/lodash": "^4.14.157",
|
|
31
31
|
"@types/node": "^10.17.26",
|
|
32
32
|
"bson": "4.0.4"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@loopback/core": "^2.9.
|
|
35
|
+
"@loopback/core": "^2.9.1",
|
|
36
36
|
"@types/debug": "^4.1.5",
|
|
37
37
|
"debug": "^4.1.1",
|
|
38
38
|
"lodash": "^4.17.15",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"url": "https://github.com/strongloop/loopback-next.git",
|
|
51
51
|
"directory": "packages/repository"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "b89db3d3b8be6a36e63e91c2331d217fda7538de"
|
|
54
54
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
// Node module: @loopback/repository
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
5
|
-
|
|
6
5
|
import {
|
|
7
6
|
DataObject,
|
|
8
7
|
Entity,
|
|
@@ -11,9 +10,10 @@ import {
|
|
|
11
10
|
HasManyDefinition,
|
|
12
11
|
} from '../..';
|
|
13
12
|
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
createTargetConstraintFromThrough,
|
|
14
|
+
createThroughConstraintFromSource,
|
|
15
|
+
createThroughConstraintFromTarget,
|
|
16
|
+
getTargetKeysFromThroughModels,
|
|
17
17
|
resolveHasManyThroughMetadata,
|
|
18
18
|
} from './has-many-through.helpers';
|
|
19
19
|
import {
|
|
@@ -33,9 +33,9 @@ export type HasManyThroughRepositoryFactory<
|
|
|
33
33
|
TargetEntity extends Entity,
|
|
34
34
|
TargetID,
|
|
35
35
|
ThroughEntity extends Entity,
|
|
36
|
-
|
|
36
|
+
SourceID
|
|
37
37
|
> = (
|
|
38
|
-
fkValue:
|
|
38
|
+
fkValue: SourceID,
|
|
39
39
|
) => HasManyThroughRepository<TargetEntity, TargetID, ThroughEntity>;
|
|
40
40
|
|
|
41
41
|
export function createHasManyThroughRepositoryFactory<
|
|
@@ -43,35 +43,41 @@ export function createHasManyThroughRepositoryFactory<
|
|
|
43
43
|
TargetID,
|
|
44
44
|
Through extends Entity,
|
|
45
45
|
ThroughID,
|
|
46
|
-
|
|
46
|
+
SourceID
|
|
47
47
|
>(
|
|
48
48
|
relationMetadata: HasManyDefinition,
|
|
49
49
|
targetRepositoryGetter: Getter<EntityCrudRepository<Target, TargetID>>,
|
|
50
50
|
throughRepositoryGetter: Getter<EntityCrudRepository<Through, ThroughID>>,
|
|
51
|
-
): HasManyThroughRepositoryFactory<Target, TargetID, Through,
|
|
51
|
+
): HasManyThroughRepositoryFactory<Target, TargetID, Through, SourceID> {
|
|
52
52
|
const meta = resolveHasManyThroughMetadata(relationMetadata);
|
|
53
|
-
const result = function (fkValue:
|
|
54
|
-
function
|
|
55
|
-
throughInstances: Through
|
|
53
|
+
const result = function (fkValue: SourceID) {
|
|
54
|
+
function getTargetConstraintFromThroughModels(
|
|
55
|
+
throughInstances: Through[],
|
|
56
56
|
): DataObject<Target> {
|
|
57
|
-
return
|
|
57
|
+
return createTargetConstraintFromThrough<Target, Through>(
|
|
58
|
+
meta,
|
|
59
|
+
throughInstances,
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
function getTargetKeys(throughInstances: Through[]): TargetID[] {
|
|
63
|
+
return getTargetKeysFromThroughModels(meta, throughInstances);
|
|
58
64
|
}
|
|
59
|
-
function
|
|
60
|
-
const
|
|
65
|
+
function getThroughConstraintFromSource(): DataObject<Through> {
|
|
66
|
+
const constraint: DataObject<Through> = createThroughConstraintFromSource<
|
|
61
67
|
Through,
|
|
62
|
-
|
|
68
|
+
SourceID
|
|
63
69
|
>(meta, fkValue);
|
|
64
|
-
return
|
|
70
|
+
return constraint;
|
|
65
71
|
}
|
|
66
72
|
|
|
67
|
-
function
|
|
68
|
-
|
|
73
|
+
function getThroughConstraintFromTarget(
|
|
74
|
+
fkValues: TargetID[],
|
|
69
75
|
): DataObject<Through> {
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
>(meta,
|
|
74
|
-
return
|
|
76
|
+
const constraint: DataObject<Through> = createThroughConstraintFromTarget<
|
|
77
|
+
Through,
|
|
78
|
+
TargetID
|
|
79
|
+
>(meta, fkValues);
|
|
80
|
+
return constraint;
|
|
75
81
|
}
|
|
76
82
|
|
|
77
83
|
return new DefaultHasManyThroughRepository<
|
|
@@ -84,9 +90,10 @@ export function createHasManyThroughRepositoryFactory<
|
|
|
84
90
|
>(
|
|
85
91
|
targetRepositoryGetter,
|
|
86
92
|
throughRepositoryGetter,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
93
|
+
getTargetConstraintFromThroughModels,
|
|
94
|
+
getTargetKeys,
|
|
95
|
+
getThroughConstraintFromSource,
|
|
96
|
+
getThroughConstraintFromTarget,
|
|
90
97
|
);
|
|
91
98
|
};
|
|
92
99
|
return result;
|
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
HasManyDefinition,
|
|
13
13
|
InvalidRelationError,
|
|
14
14
|
isTypeResolver,
|
|
15
|
-
StringKeyOf,
|
|
16
15
|
} from '../..';
|
|
17
16
|
import {resolveHasManyMetaHelper} from './has-many.helpers';
|
|
18
17
|
|
|
@@ -28,10 +27,9 @@ export type HasManyThroughResolvedDefinition = HasManyDefinition & {
|
|
|
28
27
|
};
|
|
29
28
|
|
|
30
29
|
/**
|
|
31
|
-
* Creates constraint
|
|
30
|
+
* Creates target constraint based on through models
|
|
32
31
|
* @param relationMeta - resolved hasManyThrough metadata
|
|
33
|
-
* @param throughInstances -
|
|
34
|
-
* @internal
|
|
32
|
+
* @param throughInstances - an array of through instances
|
|
35
33
|
*
|
|
36
34
|
* @example
|
|
37
35
|
* ```ts
|
|
@@ -45,8 +43,13 @@ export type HasManyThroughResolvedDefinition = HasManyDefinition & {
|
|
|
45
43
|
* keyTo: 'productId',
|
|
46
44
|
* },
|
|
47
45
|
* };
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
* createTargetConstraintFromThrough(resolvedMetadata,[{
|
|
47
|
+
id: 2,
|
|
48
|
+
categoryId: 2,
|
|
49
|
+
productId: 8,
|
|
50
|
+
}]);
|
|
51
|
+
* >>> {id: 8}
|
|
52
|
+
* createTargetConstraintFromThrough(resolvedMetadata, [
|
|
50
53
|
{
|
|
51
54
|
id: 2,
|
|
52
55
|
categoryId: 2,
|
|
@@ -61,23 +64,19 @@ export type HasManyThroughResolvedDefinition = HasManyDefinition & {
|
|
|
61
64
|
>>> {id: {inq: [9, 8]}}
|
|
62
65
|
* ```
|
|
63
66
|
*/
|
|
64
|
-
export function
|
|
67
|
+
export function createTargetConstraintFromThrough<
|
|
65
68
|
Target extends Entity,
|
|
66
69
|
Through extends Entity
|
|
67
70
|
>(
|
|
68
71
|
relationMeta: HasManyThroughResolvedDefinition,
|
|
69
|
-
throughInstances: Through
|
|
72
|
+
throughInstances: Through[],
|
|
70
73
|
): DataObject<Target> {
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
throughInstances = [throughInstances];
|
|
75
|
-
}
|
|
76
|
-
let fkValues = throughInstances.map(
|
|
77
|
-
(throughInstance: Through) =>
|
|
78
|
-
throughInstance[targetFkName as keyof Through],
|
|
74
|
+
const fkValues = getTargetKeysFromThroughModels(
|
|
75
|
+
relationMeta,
|
|
76
|
+
throughInstances,
|
|
79
77
|
);
|
|
80
|
-
|
|
78
|
+
const targetPrimaryKey = relationMeta.keyTo;
|
|
79
|
+
|
|
81
80
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
82
81
|
const constraint: any = {
|
|
83
82
|
[targetPrimaryKey]: fkValues.length === 1 ? fkValues[0] : {inq: fkValues},
|
|
@@ -86,11 +85,64 @@ export function createTargetConstraint<
|
|
|
86
85
|
}
|
|
87
86
|
|
|
88
87
|
/**
|
|
89
|
-
*
|
|
88
|
+
* Returns an array of target fks of the given throughInstances.
|
|
90
89
|
*
|
|
91
90
|
* @param relationMeta - resolved hasManyThrough metadata
|
|
92
|
-
* @param
|
|
93
|
-
*
|
|
91
|
+
* @param throughInstances - an array of through instances
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```ts
|
|
95
|
+
* const resolvedMetadata = {
|
|
96
|
+
* // .. other props
|
|
97
|
+
* keyFrom: 'id',
|
|
98
|
+
* keyTo: 'id',
|
|
99
|
+
* through: {
|
|
100
|
+
* model: () => CategoryProductLink,
|
|
101
|
+
* keyFrom: 'categoryId',
|
|
102
|
+
* keyTo: 'productId',
|
|
103
|
+
* },
|
|
104
|
+
* };
|
|
105
|
+
* getTargetKeysFromThroughModels(resolvedMetadata,[{
|
|
106
|
+
id: 2,
|
|
107
|
+
categoryId: 2,
|
|
108
|
+
productId: 8,
|
|
109
|
+
}]);
|
|
110
|
+
* >>> [8]
|
|
111
|
+
* getTargetKeysFromThroughModels(resolvedMetadata, [
|
|
112
|
+
{
|
|
113
|
+
id: 2,
|
|
114
|
+
categoryId: 2,
|
|
115
|
+
productId: 8,
|
|
116
|
+
}, {
|
|
117
|
+
id: 1,
|
|
118
|
+
categoryId: 2,
|
|
119
|
+
productId: 9,
|
|
120
|
+
}
|
|
121
|
+
]);
|
|
122
|
+
>>> [8, 9]
|
|
123
|
+
*/
|
|
124
|
+
export function getTargetKeysFromThroughModels<
|
|
125
|
+
Through extends Entity,
|
|
126
|
+
TargetID
|
|
127
|
+
>(
|
|
128
|
+
relationMeta: HasManyThroughResolvedDefinition,
|
|
129
|
+
throughInstances: Through[],
|
|
130
|
+
): TargetID[] {
|
|
131
|
+
const targetFkName = relationMeta.through.keyTo;
|
|
132
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
133
|
+
let fkValues: any = throughInstances.map(
|
|
134
|
+
(throughInstance: Through) =>
|
|
135
|
+
throughInstance[targetFkName as keyof Through],
|
|
136
|
+
);
|
|
137
|
+
fkValues = deduplicate(fkValues);
|
|
138
|
+
return fkValues as TargetID[];
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Creates through constraint based on the source key
|
|
143
|
+
*
|
|
144
|
+
* @param relationMeta - resolved hasManyThrough metadata
|
|
145
|
+
* @param fkValue - foreign key of the source instance
|
|
94
146
|
* @internal
|
|
95
147
|
*
|
|
96
148
|
* @example
|
|
@@ -105,14 +157,17 @@ export function createTargetConstraint<
|
|
|
105
157
|
* keyTo: 'productId',
|
|
106
158
|
* },
|
|
107
159
|
* };
|
|
108
|
-
*
|
|
160
|
+
* createThroughConstraintFromSource(resolvedMetadata, 1);
|
|
109
161
|
*
|
|
110
162
|
* >>> {categoryId: 1}
|
|
111
163
|
* ```
|
|
112
164
|
*/
|
|
113
|
-
export function
|
|
165
|
+
export function createThroughConstraintFromSource<
|
|
166
|
+
Through extends Entity,
|
|
167
|
+
SourceID
|
|
168
|
+
>(
|
|
114
169
|
relationMeta: HasManyThroughResolvedDefinition,
|
|
115
|
-
fkValue:
|
|
170
|
+
fkValue: SourceID,
|
|
116
171
|
): DataObject<Through> {
|
|
117
172
|
const sourceFkName = relationMeta.through.keyFrom;
|
|
118
173
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -120,10 +175,10 @@ export function createThroughConstraint<Through extends Entity, ForeignKeyType>(
|
|
|
120
175
|
return constraint;
|
|
121
176
|
}
|
|
122
177
|
/**
|
|
123
|
-
* Creates constraint
|
|
178
|
+
* Creates through constraint based on the target foreign key
|
|
124
179
|
*
|
|
125
180
|
* @param relationMeta - resolved hasManyThrough metadata
|
|
126
|
-
* @param
|
|
181
|
+
* @param fkValue an array of the target instance foreign keys
|
|
127
182
|
* @internal
|
|
128
183
|
*
|
|
129
184
|
* @example
|
|
@@ -138,25 +193,33 @@ export function createThroughConstraint<Through extends Entity, ForeignKeyType>(
|
|
|
138
193
|
* keyTo: 'productId',
|
|
139
194
|
* },
|
|
140
195
|
* };
|
|
141
|
-
*
|
|
196
|
+
* createThroughConstraintFromTarget(resolvedMetadata, [3]);
|
|
142
197
|
*
|
|
143
|
-
* >>> {productId:
|
|
198
|
+
* >>> {productId: 3}
|
|
144
199
|
*
|
|
145
|
-
*
|
|
200
|
+
* createThroughConstraintFromTarget(resolvedMetadata, [3,4]);
|
|
146
201
|
*
|
|
147
202
|
* >>> {productId: {inq:[3,4]}}
|
|
148
203
|
*/
|
|
149
|
-
export function
|
|
204
|
+
export function createThroughConstraintFromTarget<
|
|
205
|
+
Through extends Entity,
|
|
206
|
+
TargetID
|
|
207
|
+
>(
|
|
150
208
|
relationMeta: HasManyThroughResolvedDefinition,
|
|
151
|
-
|
|
209
|
+
fkValues: TargetID[],
|
|
152
210
|
): DataObject<Through> {
|
|
153
|
-
|
|
211
|
+
if (fkValues === undefined || fkValues.length === 0) {
|
|
212
|
+
throw new Error('"fkValue" must be provided');
|
|
213
|
+
}
|
|
154
214
|
const targetFkName = relationMeta.through.keyTo;
|
|
215
|
+
|
|
155
216
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
156
|
-
const constraint: any =
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
217
|
+
const constraint: any =
|
|
218
|
+
fkValues.length === 1
|
|
219
|
+
? {[targetFkName]: fkValues[0]}
|
|
220
|
+
: {[targetFkName]: {inq: fkValues}};
|
|
221
|
+
|
|
222
|
+
return constraint as DataObject<Through>;
|
|
160
223
|
}
|
|
161
224
|
|
|
162
225
|
/**
|
|
@@ -196,7 +259,7 @@ export function resolveHasManyThroughMetadata(
|
|
|
196
259
|
relationMeta.keyTo &&
|
|
197
260
|
targetModelProperties[relationMeta.keyTo]
|
|
198
261
|
) {
|
|
199
|
-
// The
|
|
262
|
+
// The explicit cast is needed because of a limitation of type inference
|
|
200
263
|
return relationMeta as HasManyThroughResolvedDefinition;
|
|
201
264
|
}
|
|
202
265
|
|
|
@@ -96,7 +96,7 @@ export interface HasManyThroughRepository<
|
|
|
96
96
|
throughData?: DataObject<Through>;
|
|
97
97
|
throughOptions?: Options;
|
|
98
98
|
},
|
|
99
|
-
): Promise<
|
|
99
|
+
): Promise<void>;
|
|
100
100
|
|
|
101
101
|
/**
|
|
102
102
|
* Removes an association to an existing target model instance
|
|
@@ -130,12 +130,13 @@ export class DefaultHasManyThroughRepository<
|
|
|
130
130
|
constructor(
|
|
131
131
|
public getTargetRepository: Getter<TargetRepository>,
|
|
132
132
|
public getThroughRepository: Getter<ThroughRepository>,
|
|
133
|
-
public
|
|
134
|
-
throughInstances: ThroughEntity
|
|
133
|
+
public getTargetConstraintFromThroughModels: (
|
|
134
|
+
throughInstances: ThroughEntity[],
|
|
135
135
|
) => DataObject<TargetEntity>,
|
|
136
|
-
public
|
|
137
|
-
public
|
|
138
|
-
|
|
136
|
+
public getTargetKeys: (throughInstances: ThroughEntity[]) => TargetID[],
|
|
137
|
+
public getThroughConstraintFromSource: () => DataObject<ThroughEntity>,
|
|
138
|
+
public getThroughConstraintFromTarget: (
|
|
139
|
+
targetID: TargetID[],
|
|
139
140
|
) => DataObject<ThroughEntity>,
|
|
140
141
|
) {}
|
|
141
142
|
|
|
@@ -147,21 +148,11 @@ export class DefaultHasManyThroughRepository<
|
|
|
147
148
|
},
|
|
148
149
|
): Promise<TargetEntity> {
|
|
149
150
|
const targetRepository = await this.getTargetRepository();
|
|
150
|
-
const throughRepository = await this.getThroughRepository();
|
|
151
151
|
const targetInstance = await targetRepository.create(
|
|
152
152
|
targetModelData,
|
|
153
153
|
options,
|
|
154
154
|
);
|
|
155
|
-
|
|
156
|
-
const throughConstraint = this.getThroughConstraint();
|
|
157
|
-
const constraints = {...targetConstraint, ...throughConstraint};
|
|
158
|
-
await throughRepository.create(
|
|
159
|
-
constrainDataObject(
|
|
160
|
-
options?.throughData ?? {},
|
|
161
|
-
constraints as DataObject<ThroughEntity>,
|
|
162
|
-
),
|
|
163
|
-
options?.throughOptions,
|
|
164
|
-
);
|
|
155
|
+
await this.link(targetInstance.getId(), options);
|
|
165
156
|
return targetInstance;
|
|
166
157
|
}
|
|
167
158
|
|
|
@@ -173,12 +164,14 @@ export class DefaultHasManyThroughRepository<
|
|
|
173
164
|
): Promise<TargetEntity[]> {
|
|
174
165
|
const targetRepository = await this.getTargetRepository();
|
|
175
166
|
const throughRepository = await this.getThroughRepository();
|
|
176
|
-
const
|
|
167
|
+
const sourceConstraint = this.getThroughConstraintFromSource();
|
|
177
168
|
const throughInstances = await throughRepository.find(
|
|
178
|
-
constrainFilter(undefined,
|
|
169
|
+
constrainFilter(undefined, sourceConstraint),
|
|
179
170
|
options?.throughOptions,
|
|
180
171
|
);
|
|
181
|
-
const targetConstraint = this.
|
|
172
|
+
const targetConstraint = this.getTargetConstraintFromThroughModels(
|
|
173
|
+
throughInstances,
|
|
174
|
+
);
|
|
182
175
|
return targetRepository.find(
|
|
183
176
|
constrainFilter(filter, targetConstraint),
|
|
184
177
|
options,
|
|
@@ -193,22 +186,24 @@ export class DefaultHasManyThroughRepository<
|
|
|
193
186
|
): Promise<Count> {
|
|
194
187
|
const targetRepository = await this.getTargetRepository();
|
|
195
188
|
const throughRepository = await this.getThroughRepository();
|
|
196
|
-
const
|
|
189
|
+
const sourceConstraint = this.getThroughConstraintFromSource();
|
|
197
190
|
const throughInstances = await throughRepository.find(
|
|
198
|
-
constrainFilter(undefined,
|
|
191
|
+
constrainFilter(undefined, sourceConstraint),
|
|
199
192
|
options?.throughOptions,
|
|
200
193
|
);
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
targetConstraint as TargetEntity,
|
|
194
|
+
const targetFkValues = this.getTargetKeys(throughInstances);
|
|
195
|
+
// delete through instances that have the targets that are going to be deleted
|
|
196
|
+
const throughFkConstraint = this.getThroughConstraintFromTarget(
|
|
197
|
+
targetFkValues,
|
|
206
198
|
);
|
|
207
199
|
await throughRepository.deleteAll(
|
|
208
|
-
constrainWhereOr({}, [
|
|
200
|
+
constrainWhereOr({}, [sourceConstraint, throughFkConstraint]),
|
|
209
201
|
);
|
|
210
202
|
|
|
211
203
|
// delete target(s)
|
|
204
|
+
const targetConstraint = this.getTargetConstraintFromThroughModels(
|
|
205
|
+
throughInstances,
|
|
206
|
+
);
|
|
212
207
|
return targetRepository.deleteAll(
|
|
213
208
|
constrainWhere(where, targetConstraint as Where<TargetEntity>),
|
|
214
209
|
options,
|
|
@@ -224,12 +219,14 @@ export class DefaultHasManyThroughRepository<
|
|
|
224
219
|
): Promise<Count> {
|
|
225
220
|
const targetRepository = await this.getTargetRepository();
|
|
226
221
|
const throughRepository = await this.getThroughRepository();
|
|
227
|
-
const
|
|
222
|
+
const sourceConstraint = this.getThroughConstraintFromSource();
|
|
228
223
|
const throughInstances = await throughRepository.find(
|
|
229
|
-
constrainFilter(undefined,
|
|
224
|
+
constrainFilter(undefined, sourceConstraint),
|
|
230
225
|
options?.throughOptions,
|
|
231
226
|
);
|
|
232
|
-
const targetConstraint = this.
|
|
227
|
+
const targetConstraint = this.getTargetConstraintFromThroughModels(
|
|
228
|
+
throughInstances,
|
|
229
|
+
);
|
|
233
230
|
return targetRepository.updateAll(
|
|
234
231
|
constrainDataObject(dataObject, targetConstraint),
|
|
235
232
|
constrainWhere(where, targetConstraint as Where<TargetEntity>),
|
|
@@ -238,21 +235,38 @@ export class DefaultHasManyThroughRepository<
|
|
|
238
235
|
}
|
|
239
236
|
|
|
240
237
|
async link(
|
|
241
|
-
|
|
238
|
+
targetId: TargetID,
|
|
242
239
|
options?: Options & {
|
|
243
240
|
throughData?: DataObject<ThroughEntity>;
|
|
244
241
|
throughOptions?: Options;
|
|
245
242
|
},
|
|
246
|
-
): Promise<
|
|
247
|
-
|
|
243
|
+
): Promise<void> {
|
|
244
|
+
const throughRepository = await this.getThroughRepository();
|
|
245
|
+
const sourceConstraint = this.getThroughConstraintFromSource();
|
|
246
|
+
const targetConstraint = this.getThroughConstraintFromTarget([targetId]);
|
|
247
|
+
const constraints = {...targetConstraint, ...sourceConstraint};
|
|
248
|
+
await throughRepository.create(
|
|
249
|
+
constrainDataObject(
|
|
250
|
+
options?.throughData ?? {},
|
|
251
|
+
constraints as DataObject<ThroughEntity>,
|
|
252
|
+
),
|
|
253
|
+
options?.throughOptions,
|
|
254
|
+
);
|
|
248
255
|
}
|
|
249
256
|
|
|
250
257
|
async unlink(
|
|
251
|
-
|
|
258
|
+
targetId: TargetID,
|
|
252
259
|
options?: Options & {
|
|
253
260
|
throughOptions?: Options;
|
|
254
261
|
},
|
|
255
262
|
): Promise<void> {
|
|
256
|
-
|
|
263
|
+
const throughRepository = await this.getThroughRepository();
|
|
264
|
+
const sourceConstraint = this.getThroughConstraintFromSource();
|
|
265
|
+
const targetConstraint = this.getThroughConstraintFromTarget([targetId]);
|
|
266
|
+
const constraints = {...targetConstraint, ...sourceConstraint};
|
|
267
|
+
await throughRepository.deleteAll(
|
|
268
|
+
constrainDataObject({}, constraints as DataObject<ThroughEntity>),
|
|
269
|
+
options?.throughOptions,
|
|
270
|
+
);
|
|
257
271
|
}
|
|
258
272
|
}
|