@loopback/repository 3.4.1 → 3.7.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/common-types.js +1 -1
- package/dist/common-types.js.map +1 -1
- package/dist/decorators/model.decorator.js +2 -1
- package/dist/decorators/model.decorator.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/mixins/repository.mixin.d.ts +13 -14
- package/dist/mixins/repository.mixin.js +6 -3
- package/dist/mixins/repository.mixin.js.map +1 -1
- package/dist/model.d.ts +2 -2
- package/dist/model.js.map +1 -1
- package/dist/relations/belongs-to/belongs-to.accessor.js.map +1 -1
- package/dist/relations/belongs-to/belongs-to.decorator.js +3 -0
- package/dist/relations/belongs-to/belongs-to.decorator.js.map +1 -1
- package/dist/relations/belongs-to/belongs-to.repository.js.map +1 -1
- package/dist/relations/has-many/has-many-through.helpers.js.map +1 -1
- package/dist/relations/has-many/has-many-through.inclusion-resolver.js.map +1 -1
- package/dist/relations/has-many/has-many-through.repository.d.ts +11 -0
- package/dist/relations/has-many/has-many-through.repository.js +9 -0
- package/dist/relations/has-many/has-many-through.repository.js.map +1 -1
- package/dist/relations/has-many/has-many.helpers.js.map +1 -1
- package/dist/relations/has-many/has-many.repository.js.map +1 -1
- package/dist/relations/has-one/has-one.helpers.js.map +1 -1
- package/dist/relations/has-one/has-one.repository.js.map +1 -1
- package/dist/relations/relation.helpers.js.map +1 -1
- package/dist/repositories/kv.repository.bridge.js +2 -1
- package/dist/repositories/kv.repository.bridge.js.map +1 -1
- package/dist/repositories/legacy-juggler-bridge.js.map +1 -1
- package/dist/repositories/repository.js.map +1 -1
- package/package.json +28 -28
- package/src/define-model-class.ts +2 -2
- package/src/define-repository-class.ts +4 -4
- package/src/index.ts +5 -0
- package/src/mixins/repository.mixin.ts +11 -8
- package/src/model.ts +2 -2
- package/src/relations/belongs-to/belongs-to.accessor.ts +21 -23
- package/src/relations/belongs-to/belongs-to.inclusion-resolver.ts +1 -1
- package/src/relations/belongs-to/belongs-to.repository.ts +3 -2
- package/src/relations/has-many/has-many-through.helpers.ts +4 -4
- package/src/relations/has-many/has-many-through.inclusion-resolver.ts +2 -2
- package/src/relations/has-many/has-many-through.repository-factory.ts +2 -2
- package/src/relations/has-many/has-many-through.repository.ts +44 -15
- package/src/relations/has-many/has-many.inclusion-resolver.ts +1 -1
- package/src/relations/has-many/has-many.repository-factory.ts +2 -2
- package/src/relations/has-many/has-many.repository.ts +3 -2
- package/src/relations/has-one/has-one.inclusion-resolver.ts +1 -1
- package/src/relations/has-one/has-one.repository-factory.ts +2 -2
- package/src/relations/has-one/has-one.repository.ts +3 -2
- package/src/relations/relation.helpers.ts +3 -3
- package/src/repositories/kv.repository.bridge.ts +4 -4
- package/src/repositories/legacy-juggler-bridge.ts +11 -9
- package/src/repositories/repository.ts +5 -4
- package/src/type-resolver.ts +1 -1
- package/CHANGELOG.md +0 -1889
|
@@ -30,7 +30,7 @@ const debug = debugFactory('loopback:repository:relation-helpers');
|
|
|
30
30
|
export async function findByForeignKeys<
|
|
31
31
|
Target extends Entity,
|
|
32
32
|
TargetRelations extends object,
|
|
33
|
-
ForeignKey extends StringKeyOf<Target
|
|
33
|
+
ForeignKey extends StringKeyOf<Target>,
|
|
34
34
|
>(
|
|
35
35
|
targetRepository: EntityCrudRepository<Target, unknown, TargetRelations>,
|
|
36
36
|
fkName: ForeignKey,
|
|
@@ -48,7 +48,7 @@ export async function findByForeignKeys<
|
|
|
48
48
|
value = fkValues;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
const where =
|
|
51
|
+
const where = {[fkName]: value} as unknown as Where<Target>;
|
|
52
52
|
|
|
53
53
|
if (scope && !_.isEmpty(scope)) {
|
|
54
54
|
// combine where clause to scope filter
|
|
@@ -74,7 +74,7 @@ export type StringKeyOf<T> = Extract<keyof T, string>;
|
|
|
74
74
|
|
|
75
75
|
export async function includeRelatedModels<
|
|
76
76
|
T extends Entity,
|
|
77
|
-
Relations extends object = {}
|
|
77
|
+
Relations extends object = {},
|
|
78
78
|
>(
|
|
79
79
|
targetRepository: EntityCrudRepository<T, unknown, Relations>,
|
|
80
80
|
entities: T[],
|
|
@@ -13,7 +13,8 @@ import {ensurePromise, juggler} from './legacy-juggler-bridge';
|
|
|
13
13
|
* An implementation of KeyValueRepository based on loopback-datasource-juggler
|
|
14
14
|
*/
|
|
15
15
|
export class DefaultKeyValueRepository<T extends Model>
|
|
16
|
-
implements KeyValueRepository<T>
|
|
16
|
+
implements KeyValueRepository<T>
|
|
17
|
+
{
|
|
17
18
|
/**
|
|
18
19
|
* A legacy KeyValueModel class
|
|
19
20
|
*/
|
|
@@ -29,9 +30,8 @@ export class DefaultKeyValueRepository<T extends Model>
|
|
|
29
30
|
) {
|
|
30
31
|
// KVModel class is placeholder to receive methods from KeyValueAccessObject
|
|
31
32
|
// through mixin
|
|
32
|
-
this.kvModelClass =
|
|
33
|
-
'_kvModel'
|
|
34
|
-
);
|
|
33
|
+
this.kvModelClass =
|
|
34
|
+
ds.createModel<typeof juggler.KeyValueModel>('_kvModel');
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
delete(key: string, options?: Options): Promise<void> {
|
|
@@ -111,8 +111,9 @@ export function ensurePromise<T>(p: legacy.PromiseOrVoid<T>): Promise<T> {
|
|
|
111
111
|
export class DefaultCrudRepository<
|
|
112
112
|
T extends Entity,
|
|
113
113
|
ID,
|
|
114
|
-
Relations extends object = {}
|
|
115
|
-
> implements EntityCrudRepository<T, ID, Relations>
|
|
114
|
+
Relations extends object = {},
|
|
115
|
+
> implements EntityCrudRepository<T, ID, Relations>
|
|
116
|
+
{
|
|
116
117
|
modelClass: juggler.PersistedModelClass;
|
|
117
118
|
|
|
118
119
|
public readonly inclusionResolvers: Map<
|
|
@@ -236,7 +237,7 @@ export class DefaultCrudRepository<
|
|
|
236
237
|
protected _createHasManyRepositoryFactoryFor<
|
|
237
238
|
Target extends Entity,
|
|
238
239
|
TargetID,
|
|
239
|
-
ForeignKeyType
|
|
240
|
+
ForeignKeyType,
|
|
240
241
|
>(
|
|
241
242
|
relationName: string,
|
|
242
243
|
targetRepoGetter: Getter<EntityCrudRepository<Target, TargetID>>,
|
|
@@ -278,7 +279,7 @@ export class DefaultCrudRepository<
|
|
|
278
279
|
protected createHasManyRepositoryFactoryFor<
|
|
279
280
|
Target extends Entity,
|
|
280
281
|
TargetID,
|
|
281
|
-
ForeignKeyType
|
|
282
|
+
ForeignKeyType,
|
|
282
283
|
>(
|
|
283
284
|
relationName: string,
|
|
284
285
|
targetRepoGetter: Getter<EntityCrudRepository<Target, TargetID>>,
|
|
@@ -325,7 +326,7 @@ export class DefaultCrudRepository<
|
|
|
325
326
|
TargetID,
|
|
326
327
|
Through extends Entity,
|
|
327
328
|
ThroughID,
|
|
328
|
-
ForeignKeyType
|
|
329
|
+
ForeignKeyType,
|
|
329
330
|
>(
|
|
330
331
|
relationName: string,
|
|
331
332
|
targetRepoGetter: Getter<EntityCrudRepository<Target, TargetID>>,
|
|
@@ -390,7 +391,7 @@ export class DefaultCrudRepository<
|
|
|
390
391
|
protected _createHasOneRepositoryFactoryFor<
|
|
391
392
|
Target extends Entity,
|
|
392
393
|
TargetID,
|
|
393
|
-
ForeignKeyType
|
|
394
|
+
ForeignKeyType,
|
|
394
395
|
>(
|
|
395
396
|
relationName: string,
|
|
396
397
|
targetRepoGetter: Getter<EntityCrudRepository<Target, TargetID>>,
|
|
@@ -410,7 +411,7 @@ export class DefaultCrudRepository<
|
|
|
410
411
|
protected createHasOneRepositoryFactoryFor<
|
|
411
412
|
Target extends Entity,
|
|
412
413
|
TargetID,
|
|
413
|
-
ForeignKeyType
|
|
414
|
+
ForeignKeyType,
|
|
414
415
|
>(
|
|
415
416
|
relationName: string,
|
|
416
417
|
targetRepoGetter: Getter<EntityCrudRepository<Target, TargetID>>,
|
|
@@ -770,10 +771,11 @@ export class DefaultCrudRepository<
|
|
|
770
771
|
export class DefaultTransactionalRepository<
|
|
771
772
|
T extends Entity,
|
|
772
773
|
ID,
|
|
773
|
-
Relations extends object = {}
|
|
774
|
+
Relations extends object = {},
|
|
774
775
|
>
|
|
775
776
|
extends DefaultCrudRepository<T, ID, Relations>
|
|
776
|
-
implements TransactionalEntityRepository<T, ID, Relations>
|
|
777
|
+
implements TransactionalEntityRepository<T, ID, Relations>
|
|
778
|
+
{
|
|
777
779
|
async beginTransaction(
|
|
778
780
|
options?: IsolationLevel | Options,
|
|
779
781
|
): Promise<Transaction> {
|
|
@@ -46,7 +46,7 @@ export interface ExecutableRepository<T extends Model> extends Repository<T> {
|
|
|
46
46
|
export type TransactionalEntityRepository<
|
|
47
47
|
T extends Entity,
|
|
48
48
|
ID,
|
|
49
|
-
Relations extends object = {}
|
|
49
|
+
Relations extends object = {},
|
|
50
50
|
> = TransactionalRepository<T> & EntityCrudRepository<T, ID>;
|
|
51
51
|
/**
|
|
52
52
|
* Repository Interface for Repositories that support Transactions
|
|
@@ -69,7 +69,7 @@ export interface TransactionalRepository<T extends Entity>
|
|
|
69
69
|
*/
|
|
70
70
|
export interface CrudRepository<
|
|
71
71
|
T extends ValueObject | Entity,
|
|
72
|
-
Relations extends object = {}
|
|
72
|
+
Relations extends object = {},
|
|
73
73
|
> extends Repository<T> {
|
|
74
74
|
/**
|
|
75
75
|
* Create a new record
|
|
@@ -137,7 +137,7 @@ export interface EntityRepository<T extends Entity, ID>
|
|
|
137
137
|
export interface EntityCrudRepository<
|
|
138
138
|
T extends Entity,
|
|
139
139
|
ID,
|
|
140
|
-
Relations extends object = {}
|
|
140
|
+
Relations extends object = {},
|
|
141
141
|
> extends EntityRepository<T, ID>,
|
|
142
142
|
CrudRepository<T, Relations> {
|
|
143
143
|
// entityClass should have type "typeof T", but that's not supported by TSC
|
|
@@ -254,7 +254,8 @@ export interface EntityCrudRepository<
|
|
|
254
254
|
* ```
|
|
255
255
|
*/
|
|
256
256
|
export class CrudRepositoryImpl<T extends Entity, ID>
|
|
257
|
-
implements EntityCrudRepository<T, ID>
|
|
257
|
+
implements EntityCrudRepository<T, ID>
|
|
258
|
+
{
|
|
258
259
|
private connector: CrudConnector;
|
|
259
260
|
public readonly inclusionResolvers: Map<
|
|
260
261
|
string,
|