@loopback/repository 1.15.4 → 1.18.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 +60 -0
- package/dist/common-types.d.ts +10 -1
- package/dist/common-types.js +1 -0
- package/dist/common-types.js.map +1 -1
- package/dist/decorators/model.decorator.js +7 -6
- package/dist/decorators/model.decorator.js.map +1 -1
- package/dist/decorators/repository.decorator.js +5 -2
- package/dist/decorators/repository.decorator.js.map +1 -1
- package/dist/define-model-class.d.ts +55 -0
- package/dist/define-model-class.js +60 -0
- package/dist/define-model-class.js.map +1 -0
- package/dist/errors/invalid-relation.error.js +2 -1
- package/dist/errors/invalid-relation.error.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/mixins/repository.mixin.js +11 -4
- package/dist/mixins/repository.mixin.js.map +1 -1
- package/dist/model.js +2 -2
- package/dist/model.js.map +1 -1
- package/dist/query.js +8 -5
- package/dist/query.js.map +1 -1
- package/dist/relations/belongs-to/belongs-to-accessor.js +12 -3
- package/dist/relations/belongs-to/belongs-to-accessor.js.map +1 -1
- package/dist/relations/belongs-to/belongs-to.helpers.js +5 -2
- package/dist/relations/belongs-to/belongs-to.helpers.js.map +1 -1
- package/dist/relations/has-many/has-many-repository.factory.js +5 -2
- package/dist/relations/has-many/has-many-repository.factory.js.map +1 -1
- package/dist/relations/has-many/has-many-through.repository.d.ts +66 -0
- package/dist/relations/has-many/has-many-through.repository.js +7 -0
- package/dist/relations/has-many/has-many-through.repository.js.map +1 -0
- package/dist/relations/has-many/has-many.helpers.js +18 -4
- package/dist/relations/has-many/has-many.helpers.js.map +1 -1
- package/dist/relations/has-many/has-many.inclusion-resolver.js +5 -2
- package/dist/relations/has-many/has-many.inclusion-resolver.js.map +1 -1
- package/dist/relations/has-one/has-one-repository.factory.js +5 -2
- package/dist/relations/has-one/has-one-repository.factory.js.map +1 -1
- package/dist/relations/has-one/has-one.helpers.js +14 -3
- package/dist/relations/has-one/has-one.helpers.js.map +1 -1
- package/dist/relations/relation.decorator.js +2 -1
- package/dist/relations/relation.decorator.js.map +1 -1
- package/dist/relations/relation.helpers.d.ts +1 -1
- package/dist/relations/relation.helpers.js +18 -13
- package/dist/relations/relation.helpers.js.map +1 -1
- package/dist/relations/relation.types.d.ts +50 -3
- package/dist/relations/relation.types.js.map +1 -1
- package/dist/repositories/kv.repository.bridge.d.ts +3 -3
- package/dist/repositories/kv.repository.bridge.js +1 -1
- package/dist/repositories/kv.repository.bridge.js.map +1 -1
- package/dist/repositories/legacy-juggler-bridge.d.ts +20 -1
- package/dist/repositories/legacy-juggler-bridge.js +82 -20
- package/dist/repositories/legacy-juggler-bridge.js.map +1 -1
- package/dist/types/array.js +5 -2
- package/dist/types/array.js.map +1 -1
- package/dist/types/buffer.d.ts +1 -1
- package/dist/types/buffer.js +8 -4
- package/dist/types/buffer.js.map +1 -1
- package/dist/types/date.js +5 -2
- package/dist/types/date.js.map +1 -1
- package/dist/types/number.js +5 -2
- package/dist/types/number.js.map +1 -1
- package/dist/types/object.d.ts +1 -1
- package/dist/types/object.js +5 -2
- package/dist/types/object.js.map +1 -1
- package/dist/types/union.js +5 -2
- package/dist/types/union.js.map +1 -1
- package/package.json +12 -12
- package/src/common-types.ts +15 -1
- package/src/decorators/model.decorator.ts +5 -5
- package/src/decorators/repository.decorator.ts +1 -1
- package/src/define-model-class.ts +88 -0
- package/src/errors/invalid-relation.error.ts +1 -1
- package/src/index.ts +1 -0
- package/src/mixins/repository.mixin.ts +7 -3
- package/src/model.ts +2 -2
- package/src/query.ts +3 -3
- package/src/relations/belongs-to/belongs-to-accessor.ts +8 -2
- package/src/relations/belongs-to/belongs-to.helpers.ts +1 -1
- package/src/relations/has-many/has-many-repository.factory.ts +1 -1
- package/src/relations/has-many/has-many-through.repository.ts +100 -0
- package/src/relations/has-many/has-many.helpers.ts +15 -4
- package/src/relations/has-many/has-many.inclusion-resolver.ts +1 -1
- package/src/relations/has-one/has-one-repository.factory.ts +1 -1
- package/src/relations/has-one/has-one.helpers.ts +11 -2
- package/src/relations/relation.decorator.ts +1 -1
- package/src/relations/relation.helpers.ts +13 -12
- package/src/relations/relation.types.ts +56 -2
- package/src/repositories/kv.repository.bridge.ts +5 -8
- package/src/repositories/legacy-juggler-bridge.ts +81 -13
- package/src/types/array.ts +1 -1
- package/src/types/buffer.ts +4 -4
- package/src/types/date.ts +1 -1
- package/src/types/number.ts +1 -1
- package/src/types/object.ts +2 -2
- package/src/types/union.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"belongs-to.helpers.js","sourceRoot":"","sources":["../../../src/relations/belongs-to/belongs-to.helpers.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE
|
|
1
|
+
{"version":3,"file":"belongs-to.helpers.js","sourceRoot":"","sources":["../../../src/relations/belongs-to/belongs-to.helpers.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;;;AAEhE,kDAAiC;AACjC,yCAAkD;AAClD,uDAAmD;AACnD,sDAAoE;AAEpE,MAAM,KAAK,GAAG,eAAY,CAAC,wCAAwC,CAAC,CAAC;AAQrE;;;;;;GAMG;AACH,SAAgB,wBAAwB,CAAC,YAAiC;IACxE,IAAK,YAAY,CAAC,IAAqB,KAAK,6BAAY,CAAC,SAAS,EAAE;QAClE,MAAM,MAAM,GAAG,iCAAiC,CAAC;QACjD,MAAM,IAAI,6BAAoB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;KACtD;IAED,IAAI,CAAC,8BAAc,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE;QACxC,MAAM,MAAM,GAAG,gCAAgC,CAAC;QAChD,MAAM,IAAI,6BAAoB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;KACtD;IAED,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE;QACzB,MAAM,MAAM,GAAG,qBAAqB,CAAC;QACrC,MAAM,IAAI,6BAAoB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;KACtD;IAED,MAAM,WAAW,GAAG,YAAY,CAAC,MAAM,CAAC;IACxC,IAAI,CAAC,WAAW,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE;QAC1C,MAAM,MAAM,GAAG,8BAA8B,CAAC;QAC9C,MAAM,IAAI,6BAAoB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;KACtD;IAED,MAAM,WAAW,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC;IAC1C,MAAM,UAAU,GAAG,WAAW,CAAC,SAAS,CAAC;IACzC,KAAK,CAAC,2CAA2C,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;IAE5E,MAAM,gBAAgB,GAAG,WAAW,CAAC,UAAU,CAAC,UAAU,CAAC;IAC3D,KAAK,CAAC,+BAA+B,EAAE,UAAU,EAAE,gBAAgB,CAAC,CAAC;IAErE,IAAI,YAAY,CAAC,KAAK,IAAI,gBAAgB,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE;QAC9D,wEAAwE;QACxE,OAAO,YAA2C,CAAC;KACpD;IAED,MAAM,gBAAgB,GAAG,WAAW,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC;IAClE,IAAI,CAAC,gBAAgB,EAAE;QACrB,MAAM,MAAM,GAAG,GAAG,UAAU,8CAA8C,CAAC;QAC3E,MAAM,IAAI,6BAAoB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;KACtD;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,EAAC,KAAK,EAAE,gBAAgB,EAAC,CAAC,CAAC;AAChE,CAAC;AAzCD,4DAyCC"}
|
|
@@ -3,12 +3,15 @@
|
|
|
3
3
|
// Node module: @loopback/repository
|
|
4
4
|
// This file is licensed under the MIT License.
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
6
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const
|
|
10
|
+
const debug_1 = __importDefault(require("debug"));
|
|
8
11
|
const has_many_helpers_1 = require("./has-many.helpers");
|
|
9
12
|
const has_many_inclusion_resolver_1 = require("./has-many.inclusion-resolver");
|
|
10
13
|
const has_many_repository_1 = require("./has-many.repository");
|
|
11
|
-
const debug =
|
|
14
|
+
const debug = debug_1.default('loopback:repository:has-many-repository-factory');
|
|
12
15
|
/**
|
|
13
16
|
* Enforces a constraint on a repository based on a relationship contract
|
|
14
17
|
* between models. For example, if a Customer model is related to an Order model
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"has-many-repository.factory.js","sourceRoot":"","sources":["../../../src/relations/has-many/has-many-repository.factory.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE
|
|
1
|
+
{"version":3,"file":"has-many-repository.factory.js","sourceRoot":"","sources":["../../../src/relations/has-many/has-many-repository.factory.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;;;AAEhE,kDAAiC;AAKjC,yDAA0D;AAC1D,+EAA6E;AAC7E,+DAG+B;AAE/B,MAAM,KAAK,GAAG,eAAY,CAAC,iDAAiD,CAAC,CAAC;AAiB9E;;;;;;;;;;;;GAYG;AACH,SAAgB,8BAA8B,CAK5C,gBAAmC,EACnC,sBAAsE;IAEtE,MAAM,IAAI,GAAG,yCAAsB,CAAC,gBAAgB,CAAC,CAAC;IACtD,KAAK,CAAC,wCAAwC,EAAE,IAAI,CAAC,CAAC;IACtD,MAAM,MAAM,GAAqD,UAC/D,OAAuB;QAEvB,8DAA8D;QAC9D,MAAM,UAAU,GAAQ,EAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,OAAO,EAAC,CAAC;QAChD,OAAO,IAAI,8CAAwB,CAIjC,sBAAsB,EAAE,UAAgC,CAAC,CAAC;IAC9D,CAAC,CAAC;IACF,MAAM,CAAC,iBAAiB,GAAG,4DAA8B,CACvD,IAAI,EACJ,sBAAsB,CACvB,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC;AA1BD,wEA0BC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Count, DataObject, Entity, Filter, Options, Where } from '../..';
|
|
2
|
+
/**
|
|
3
|
+
* CRUD operations for a target repository of a HasManyThrough relation
|
|
4
|
+
*
|
|
5
|
+
* EXPERIMENTAL: This interface is not stable and may change in the near future.
|
|
6
|
+
* Backwards-incompatible changes may be introduced in semver-minor versions.
|
|
7
|
+
*/
|
|
8
|
+
export interface HasManyThroughRepository<Target extends Entity, TargetID, Through extends Entity> {
|
|
9
|
+
/**
|
|
10
|
+
* Create a target model instance
|
|
11
|
+
* @param targetModelData - The target model data
|
|
12
|
+
* @param options - Options for the operation
|
|
13
|
+
* @returns A promise which resolves to the newly created target model instance
|
|
14
|
+
*/
|
|
15
|
+
create(targetModelData: DataObject<Target>, options?: Options & {
|
|
16
|
+
throughData?: DataObject<Through>;
|
|
17
|
+
throughOptions?: Options;
|
|
18
|
+
}): Promise<Target>;
|
|
19
|
+
/**
|
|
20
|
+
* Find target model instance(s)
|
|
21
|
+
* @param filter - A filter object for where, order, limit, etc.
|
|
22
|
+
* @param options - Options for the operation
|
|
23
|
+
* @returns A promise which resolves with the found target instance(s)
|
|
24
|
+
*/
|
|
25
|
+
find(filter?: Filter<Target>, options?: Options & {
|
|
26
|
+
throughOptions?: Options;
|
|
27
|
+
}): Promise<Target[]>;
|
|
28
|
+
/**
|
|
29
|
+
* Delete multiple target model instances
|
|
30
|
+
* @param where - Instances within the where scope are deleted
|
|
31
|
+
* @param options
|
|
32
|
+
* @returns A promise which resolves the deleted target model instances
|
|
33
|
+
*/
|
|
34
|
+
delete(where?: Where<Target>, options?: Options & {
|
|
35
|
+
throughOptions?: Options;
|
|
36
|
+
}): Promise<Count>;
|
|
37
|
+
/**
|
|
38
|
+
* Patch multiple target model instances
|
|
39
|
+
* @param dataObject - The fields and their new values to patch
|
|
40
|
+
* @param where - Instances within the where scope are patched
|
|
41
|
+
* @param options
|
|
42
|
+
* @returns A promise which resolves the patched target model instances
|
|
43
|
+
*/
|
|
44
|
+
patch(dataObject: DataObject<Target>, where?: Where<Target>, options?: Options & {
|
|
45
|
+
throughOptions?: Options;
|
|
46
|
+
}): Promise<Count>;
|
|
47
|
+
/**
|
|
48
|
+
* Creates a new many-to-many association to an existing target model instance
|
|
49
|
+
* @param targetModelId - The target model ID to link
|
|
50
|
+
* @param options
|
|
51
|
+
* @returns A promise which resolves to the linked target model instance
|
|
52
|
+
*/
|
|
53
|
+
link(targetModelId: TargetID, options?: Options & {
|
|
54
|
+
throughData?: DataObject<Through>;
|
|
55
|
+
throughOptions?: Options;
|
|
56
|
+
}): Promise<Target>;
|
|
57
|
+
/**
|
|
58
|
+
* Removes an association to an existing target model instance
|
|
59
|
+
* @param targetModelId - The target model to unlink
|
|
60
|
+
* @param options
|
|
61
|
+
* @returns A promise which resolves to null
|
|
62
|
+
*/
|
|
63
|
+
unlink(targetModelId: TargetID, options?: Options & {
|
|
64
|
+
throughOptions?: Options;
|
|
65
|
+
}): Promise<void>;
|
|
66
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright IBM Corp. 2020. All Rights Reserved.
|
|
3
|
+
// Node module: @loopback/repository
|
|
4
|
+
// This file is licensed under the MIT License.
|
|
5
|
+
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
//# sourceMappingURL=has-many-through.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"has-many-through.repository.js","sourceRoot":"","sources":["../../../src/relations/has-many/has-many-through.repository.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE"}
|
|
@@ -3,13 +3,16 @@
|
|
|
3
3
|
// Node module: @loopback/repository
|
|
4
4
|
// This file is licensed under the MIT License.
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
6
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const
|
|
10
|
+
const debug_1 = __importDefault(require("debug"));
|
|
8
11
|
const lodash_1 = require("lodash");
|
|
9
12
|
const errors_1 = require("../../errors");
|
|
10
13
|
const type_resolver_1 = require("../../type-resolver");
|
|
11
14
|
const relation_types_1 = require("../relation.types");
|
|
12
|
-
const debug =
|
|
15
|
+
const debug = debug_1.default('loopback:repository:has-many-helpers');
|
|
13
16
|
/**
|
|
14
17
|
* Resolves given hasMany metadata if target is specified to be a resolver.
|
|
15
18
|
* Mainly used to infer what the `keyTo` property should be from the target's
|
|
@@ -33,7 +36,15 @@ function resolveHasManyMetadata(relationMeta) {
|
|
|
33
36
|
const reason = 'source model must be defined';
|
|
34
37
|
throw new errors_1.InvalidRelationError(reason, relationMeta);
|
|
35
38
|
}
|
|
36
|
-
|
|
39
|
+
// keyFrom defaults to id property
|
|
40
|
+
let keyFrom;
|
|
41
|
+
if (relationMeta.keyFrom &&
|
|
42
|
+
relationMeta.source.definition.properties[relationMeta.keyFrom]) {
|
|
43
|
+
keyFrom = relationMeta.keyFrom;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
keyFrom = sourceModel.getIdProperties()[0];
|
|
47
|
+
}
|
|
37
48
|
// Make sure that if it already keys to the foreign key property,
|
|
38
49
|
// the key exists in the target model
|
|
39
50
|
if (relationMeta.keyTo && targetModelProperties[relationMeta.keyTo]) {
|
|
@@ -47,7 +58,10 @@ function resolveHasManyMetadata(relationMeta) {
|
|
|
47
58
|
const reason = `target model ${targetModel.name} is missing definition of foreign key ${defaultFkName}`;
|
|
48
59
|
throw new errors_1.InvalidRelationError(reason, relationMeta);
|
|
49
60
|
}
|
|
50
|
-
return Object.assign(relationMeta, {
|
|
61
|
+
return Object.assign(relationMeta, {
|
|
62
|
+
keyFrom,
|
|
63
|
+
keyTo: defaultFkName,
|
|
64
|
+
});
|
|
51
65
|
}
|
|
52
66
|
exports.resolveHasManyMetadata = resolveHasManyMetadata;
|
|
53
67
|
//# sourceMappingURL=has-many.helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"has-many.helpers.js","sourceRoot":"","sources":["../../../src/relations/has-many/has-many.helpers.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE
|
|
1
|
+
{"version":3,"file":"has-many.helpers.js","sourceRoot":"","sources":["../../../src/relations/has-many/has-many.helpers.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;;;AAEhE,kDAAiC;AACjC,mCAAiC;AACjC,yCAAkD;AAClD,uDAAmD;AACnD,sDAAkE;AAElE,MAAM,KAAK,GAAG,eAAY,CAAC,sCAAsC,CAAC,CAAC;AAWnE;;;;;;GAMG;AACH,SAAgB,sBAAsB,CACpC,YAA+B;IAE/B,IAAK,YAAY,CAAC,IAAqB,KAAK,6BAAY,CAAC,OAAO,EAAE;QAChE,MAAM,MAAM,GAAG,+BAA+B,CAAC;QAC/C,MAAM,IAAI,6BAAoB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;KACtD;IAED,IAAI,CAAC,8BAAc,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE;QACxC,MAAM,MAAM,GAAG,gCAAgC,CAAC;QAChD,MAAM,IAAI,6BAAoB,CAAC,MAAM,EAAE,YAAY,CAAC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AAC,CAAC;KACtD;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE;QACjC,OAAO;QACP,KAAK,EAAE,aAAa;KACQ,CAAC,CAAC;AAClC,CAAC;AAzDD,wDAyDC"}
|
|
@@ -3,11 +3,14 @@
|
|
|
3
3
|
// Node module: @loopback/repository
|
|
4
4
|
// This file is licensed under the MIT License.
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
6
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const
|
|
10
|
+
const debug_1 = __importDefault(require("debug"));
|
|
8
11
|
const relation_helpers_1 = require("../relation.helpers");
|
|
9
12
|
const has_many_helpers_1 = require("./has-many.helpers");
|
|
10
|
-
const debug =
|
|
13
|
+
const debug = debug_1.default('loopback:repository:has-many-inclusion-resolver');
|
|
11
14
|
/**
|
|
12
15
|
* Creates InclusionResolver for HasMany relation.
|
|
13
16
|
* Notice that this function only generates the inclusionResolver.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"has-many.inclusion-resolver.js","sourceRoot":"","sources":["../../../src/relations/has-many/has-many.inclusion-resolver.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE
|
|
1
|
+
{"version":3,"file":"has-many.inclusion-resolver.js","sourceRoot":"","sources":["../../../src/relations/has-many/has-many.inclusion-resolver.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;;;AAEhE,kDAAiC;AAKjC,0DAI6B;AAE7B,yDAA0D;AAE1D,MAAM,KAAK,GAAG,eAAY,CAAC,iDAAiD,CAAC,CAAC;AAE9E;;;;;;;;;GASG;AACH,SAAgB,8BAA8B,CAK5C,IAAuB,EACvB,aAEC;IAED,MAAM,YAAY,GAAG,yCAAsB,CAAC,IAAI,CAAC,CAAC;IAElD,OAAO,KAAK,UAAU,kBAAkB,CACtC,QAAkB,EAClB,SAA+B,EAC/B,OAAiB;QAEjB,IAAI,CAAC,QAAQ,CAAC,MAAM;YAAE,OAAO,EAAE,CAAC;QAEhC,KAAK,CAAC,sCAAsC,EAAE,QAAQ,CAAC,CAAC;QACxD,KAAK,CAAC,oBAAoB,EAAE,YAAY,CAAC,CAAC;QAE1C,MAAM,SAAS,GAAG,YAAY,CAAC,OAAO,CAAC;QACvC,MAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAE,CAAe,CAAC,SAAS,CAAC,CAAC,CAAC;QACjE,MAAM,SAAS,GAAG,YAAY,CAAC,KAA4B,CAAC;QAE5D,KAAK,CAAC,aAAa,EAAE,EAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAC,CAAC,CAAC;QACxD,KAAK,CACH,gBAAgB,EAChB,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAC7B,CAAC;QAEF,MAAM,UAAU,GAAG,MAAM,aAAa,EAAE,CAAC;QACzC,MAAM,YAAY,GAAG,MAAM,oCAAiB,CAC1C,UAAU,EACV,SAAS,EACT,SAAS,EACT,SAAS,CAAC,KAAuB,EACjC,OAAO,CACR,CAAC;QAEF,KAAK,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAAC;QAEtC,MAAM,MAAM,GAAG,oDAAiC,CAC9C,SAAS,EACT,YAAY,EACZ,SAAS,CACV,CAAC;QAEF,KAAK,CAAC,2BAA2B,EAAE,MAAM,CAAC,CAAC;QAC3C,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC;AApDD,wEAoDC"}
|
|
@@ -3,12 +3,15 @@
|
|
|
3
3
|
// Node module: @loopback/repository
|
|
4
4
|
// This file is licensed under the MIT License.
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
6
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const
|
|
10
|
+
const debug_1 = __importDefault(require("debug"));
|
|
8
11
|
const has_one_helpers_1 = require("./has-one.helpers");
|
|
9
12
|
const has_one_inclusion_resolver_1 = require("./has-one.inclusion-resolver");
|
|
10
13
|
const has_one_repository_1 = require("./has-one.repository");
|
|
11
|
-
const debug =
|
|
14
|
+
const debug = debug_1.default('loopback:repository:has-one-repository-factory');
|
|
12
15
|
/**
|
|
13
16
|
* Enforces a constraint on a repository based on a relationship contract
|
|
14
17
|
* between models. For example, if a Customer model is related to an Address model
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"has-one-repository.factory.js","sourceRoot":"","sources":["../../../src/relations/has-one/has-one-repository.factory.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE
|
|
1
|
+
{"version":3,"file":"has-one-repository.factory.js","sourceRoot":"","sources":["../../../src/relations/has-one/has-one-repository.factory.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;;;AAEhE,kDAAiC;AAKjC,uDAAwD;AACxD,6EAA2E;AAC3E,6DAA+E;AAE/E,MAAM,KAAK,GAAG,eAAY,CAAC,gDAAgD,CAAC,CAAC;AAgB7E;;;;;;;;;;;;GAYG;AACH,SAAgB,6BAA6B,CAK3C,gBAAkC,EAClC,sBAAsE;IAEtE,MAAM,IAAI,GAAG,uCAAqB,CAAC,gBAAgB,CAAC,CAAC;IACrD,KAAK,CAAC,uCAAuC,EAAE,IAAI,CAAC,CAAC;IACrD,MAAM,MAAM,GAAoD,UAC9D,OAAuB;QAEvB,8DAA8D;QAC9D,MAAM,UAAU,GAAQ,EAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,OAAO,EAAC,CAAC;QAChD,OAAO,IAAI,4CAAuB,CAIhC,sBAAsB,EAAE,UAAgC,CAAC,CAAC;IAC9D,CAAC,CAAC;IACF,MAAM,CAAC,iBAAiB,GAAG,0DAA6B,CACtD,IAAI,EACJ,sBAAsB,CACvB,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC;AA1BD,sEA0BC"}
|
|
@@ -3,13 +3,16 @@
|
|
|
3
3
|
// Node module: @loopback/repository
|
|
4
4
|
// This file is licensed under the MIT License.
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
6
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const
|
|
10
|
+
const debug_1 = __importDefault(require("debug"));
|
|
8
11
|
const lodash_1 = require("lodash");
|
|
9
12
|
const errors_1 = require("../../errors");
|
|
10
13
|
const type_resolver_1 = require("../../type-resolver");
|
|
11
14
|
const relation_types_1 = require("../relation.types");
|
|
12
|
-
const debug =
|
|
15
|
+
const debug = debug_1.default('loopback:repository:has-one-helpers');
|
|
13
16
|
/**
|
|
14
17
|
* Resolves given hasOne metadata if target is specified to be a resolver.
|
|
15
18
|
* Mainly used to infer what the `keyTo` property should be from the target's
|
|
@@ -33,7 +36,15 @@ function resolveHasOneMetadata(relationMeta) {
|
|
|
33
36
|
const reason = 'source model must be defined';
|
|
34
37
|
throw new errors_1.InvalidRelationError(reason, relationMeta);
|
|
35
38
|
}
|
|
36
|
-
|
|
39
|
+
// keyFrom defaults to id property
|
|
40
|
+
let keyFrom;
|
|
41
|
+
if (relationMeta.keyFrom &&
|
|
42
|
+
relationMeta.source.definition.properties[relationMeta.keyFrom]) {
|
|
43
|
+
keyFrom = relationMeta.keyFrom;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
keyFrom = sourceModel.getIdProperties()[0];
|
|
47
|
+
}
|
|
37
48
|
// Make sure that if it already keys to the foreign key property,
|
|
38
49
|
// the key exists in the target model
|
|
39
50
|
if (relationMeta.keyTo && targetModelProperties[relationMeta.keyTo]) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"has-one.helpers.js","sourceRoot":"","sources":["../../../src/relations/has-one/has-one.helpers.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE
|
|
1
|
+
{"version":3,"file":"has-one.helpers.js","sourceRoot":"","sources":["../../../src/relations/has-one/has-one.helpers.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;;;AAEhE,kDAAiC;AACjC,mCAAiC;AACjC,yCAAkD;AAClD,uDAAmD;AACnD,sDAAiE;AAEjE,MAAM,KAAK,GAAG,eAAY,CAAC,qCAAqC,CAAC,CAAC;AAWlE;;;;;;GAMG;AACH,SAAgB,qBAAqB,CACnC,YAA8B;IAE9B,IAAK,YAAY,CAAC,IAAqB,KAAK,6BAAY,CAAC,MAAM,EAAE;QAC/D,MAAM,MAAM,GAAG,8BAA8B,CAAC;QAC9C,MAAM,IAAI,6BAAoB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;KACtD;IAED,IAAI,CAAC,8BAAc,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE;QACxC,MAAM,MAAM,GAAG,gCAAgC,CAAC;QAChD,MAAM,IAAI,6BAAoB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;KACtD;IAED,MAAM,WAAW,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC;IAC1C,MAAM,qBAAqB,GACzB,WAAW,CAAC,UAAU,IAAI,WAAW,CAAC,UAAU,CAAC,UAAU,CAAC;IAE9D,MAAM,WAAW,GAAG,YAAY,CAAC,MAAM,CAAC;IACxC,IAAI,CAAC,WAAW,IAAI,CA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
29
|
function getModelRelations(modelCtor) {
|
|
30
|
+
var _a;
|
|
30
31
|
// Build model definitions if `@model` is missing
|
|
31
32
|
const modelDef = decorators_1.buildModelDefinition(modelCtor);
|
|
32
|
-
return (modelDef
|
|
33
|
+
return ((_a = modelDef) === null || _a === void 0 ? void 0 : _a.relations) || {};
|
|
33
34
|
}
|
|
34
35
|
exports.getModelRelations = getModelRelations;
|
|
35
36
|
//
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relation.decorator.js","sourceRoot":"","sources":["../../src/relations/relation.decorator.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;AAEhE,+CAA2D;AAC3D,8CAAmD;AAEnD,qDAA8C;AAEjC,QAAA,aAAa,GAAG,oBAAoB,CAAC;AAElD;;;;GAIG;AACH,SAAgB,QAAQ,CAAC,UAAmB;IAC1C,+CAA+C;IAC/C,OAAO,kCAAwB,CAAC,eAAe,CAAC,qBAAa,EAAE,UAAU,EAAE;QACzE,aAAa,EAAE,WAAW;KAC3B,CAAC,CAAC;AACL,CAAC;AALD,4BAKC;AAED;;;;;GAKG;AACH,SAAgB,iBAAiB,CAC/B,SAAuB
|
|
1
|
+
{"version":3,"file":"relation.decorator.js","sourceRoot":"","sources":["../../src/relations/relation.decorator.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;AAEhE,+CAA2D;AAC3D,8CAAmD;AAEnD,qDAA8C;AAEjC,QAAA,aAAa,GAAG,oBAAoB,CAAC;AAElD;;;;GAIG;AACH,SAAgB,QAAQ,CAAC,UAAmB;IAC1C,+CAA+C;IAC/C,OAAO,kCAAwB,CAAC,eAAe,CAAC,qBAAa,EAAE,UAAU,EAAE;QACzE,aAAa,EAAE,WAAW;KAC3B,CAAC,CAAC;AACL,CAAC;AALD,4BAKC;AAED;;;;;GAKG;AACH,SAAgB,iBAAiB,CAC/B,S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AAE,UAAU,CAAC,CAAC;IAC3E,OAAO,kCAAwB,CAAC,eAAe,CAAC,qBAAa,EAAE,GAAG,EAAE;QAClE,aAAa,EAAE,iBAAiB;KACjC,CAAC,CAAC;AACL,CAAC;AALD,wCAKC"}
|
|
@@ -2,7 +2,7 @@ import { AnyObject, Entity, EntityCrudRepository, Filter, Inclusion, Options } f
|
|
|
2
2
|
/**
|
|
3
3
|
* Finds model instances that contain any of the provided foreign key values.
|
|
4
4
|
*
|
|
5
|
-
* @param targetRepository - The target repository where the model instances are found
|
|
5
|
+
* @param targetRepository - The target repository where the related model instances are found
|
|
6
6
|
* @param fkName - Name of the foreign key
|
|
7
7
|
* @param fkValues - One value or array of values of the foreign key to be included
|
|
8
8
|
* @param scope - Additional scope constraints (not currently supported)
|
|
@@ -3,26 +3,25 @@
|
|
|
3
3
|
// Node module: @loopback/repository
|
|
4
4
|
// This file is licensed under the MIT License.
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
6
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
10
|
+
const assert_1 = __importDefault(require("assert"));
|
|
11
|
+
const debug_1 = __importDefault(require("debug"));
|
|
12
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
13
|
+
const __1 = require("..");
|
|
14
|
+
const debug = debug_1.default('loopback:repository:relation-helpers');
|
|
11
15
|
/**
|
|
12
16
|
* Finds model instances that contain any of the provided foreign key values.
|
|
13
17
|
*
|
|
14
|
-
* @param targetRepository - The target repository where the model instances are found
|
|
18
|
+
* @param targetRepository - The target repository where the related model instances are found
|
|
15
19
|
* @param fkName - Name of the foreign key
|
|
16
20
|
* @param fkValues - One value or array of values of the foreign key to be included
|
|
17
21
|
* @param scope - Additional scope constraints (not currently supported)
|
|
18
22
|
* @param options - Options for the operations
|
|
19
23
|
*/
|
|
20
24
|
async function findByForeignKeys(targetRepository, fkName, fkValues, scope, options) {
|
|
21
|
-
// throw error if scope is defined and non-empty
|
|
22
|
-
// see https://github.com/strongloop/loopback-next/issues/3453
|
|
23
|
-
if (scope && !_.isEmpty(scope)) {
|
|
24
|
-
throw new Error('scope is not supported');
|
|
25
|
-
}
|
|
26
25
|
let value;
|
|
27
26
|
if (Array.isArray(fkValues)) {
|
|
28
27
|
if (fkValues.length === 0)
|
|
@@ -40,8 +39,14 @@ async function findByForeignKeys(targetRepository, fkName, fkValues, scope, opti
|
|
|
40
39
|
value = fkValues;
|
|
41
40
|
}
|
|
42
41
|
const where = { [fkName]: value };
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
if (scope && !lodash_1.default.isEmpty(scope)) {
|
|
43
|
+
// combine where clause to scope filter
|
|
44
|
+
scope = new __1.FilterBuilder(scope).impose({ where }).filter;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
scope = { where };
|
|
48
|
+
}
|
|
49
|
+
return targetRepository.find(scope, options);
|
|
45
50
|
}
|
|
46
51
|
exports.findByForeignKeys = findByForeignKeys;
|
|
47
52
|
/**
|
|
@@ -233,7 +238,7 @@ function deduplicate(input) {
|
|
|
233
238
|
if (!input) {
|
|
234
239
|
return uniqArray;
|
|
235
240
|
}
|
|
236
|
-
|
|
241
|
+
assert_1.default(Array.isArray(input), 'array argument is required');
|
|
237
242
|
const comparableArray = input.map(item => normalizeKey(item));
|
|
238
243
|
for (let i = 0, n = comparableArray.length; i < n; i++) {
|
|
239
244
|
if (comparableArray.indexOf(comparableArray[i]) === i) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relation.helpers.js","sourceRoot":"","sources":["../../src/relations/relation.helpers.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE
|
|
1
|
+
{"version":3,"file":"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AAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IAEtD,wEAAwE;IACxE,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IAE1D,SAAS,KAAK,CAAC,MAAe;QAC5B,OAAO,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACnE,CAAC;AACH,CAAC;AATD,gCASC"}
|
|
@@ -44,13 +44,56 @@ export interface HasManyDefinition extends RelationDefinitionBase {
|
|
|
44
44
|
type: RelationType.hasMany;
|
|
45
45
|
targetsMany: true;
|
|
46
46
|
/**
|
|
47
|
-
* The foreign key used by the target model.
|
|
47
|
+
* keyTo: The foreign key used by the target model for this relation.
|
|
48
|
+
* keyFrom: The source key used by the source model for this relation.
|
|
48
49
|
*
|
|
49
50
|
* E.g. when a Customer has many Order instances, then keyTo is "customerId".
|
|
50
51
|
* Note that "customerId" is the default FK assumed by the framework, users
|
|
51
52
|
* can provide a custom FK name by setting "keyTo".
|
|
53
|
+
* And Customer.id is keyFrom. keyFrom defaults to the id property of a model.
|
|
54
|
+
* Users can provide a custom source key name by setting "keyTo".
|
|
55
|
+
*
|
|
52
56
|
*/
|
|
53
57
|
keyTo?: string;
|
|
58
|
+
keyFrom?: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* A `hasManyThrough` relation defines a many-to-many connection with another model.
|
|
62
|
+
* This relation indicates that the declaring model can be matched with zero or more
|
|
63
|
+
* instances of another model by proceeding through a third model.
|
|
64
|
+
*
|
|
65
|
+
* Warning: The hasManyThrough interface is experimental and is subject to change.
|
|
66
|
+
* If backwards-incompatible changes are made, a new major version may not be
|
|
67
|
+
* released.
|
|
68
|
+
*/
|
|
69
|
+
export interface HasManyThroughDefinition extends RelationDefinitionBase {
|
|
70
|
+
type: RelationType.hasMany;
|
|
71
|
+
targetsMany: true;
|
|
72
|
+
/**
|
|
73
|
+
* The foreign key in the source model, e.g. Customer#id.
|
|
74
|
+
*/
|
|
75
|
+
keyFrom: string;
|
|
76
|
+
/**
|
|
77
|
+
* The primary key of the target model, e.g Seller#id.
|
|
78
|
+
*/
|
|
79
|
+
keyTo: string;
|
|
80
|
+
through: {
|
|
81
|
+
/**
|
|
82
|
+
* The through model of this relation.
|
|
83
|
+
*
|
|
84
|
+
* E.g. when a Customer has many Order instances and a Seller has many Order instances,
|
|
85
|
+
* then Order is through.
|
|
86
|
+
*/
|
|
87
|
+
model: TypeResolver<Entity, typeof Entity>;
|
|
88
|
+
/**
|
|
89
|
+
* The foreign key of the source model defined in the through model, e.g. Order#customerId
|
|
90
|
+
*/
|
|
91
|
+
keyFrom: string;
|
|
92
|
+
/**
|
|
93
|
+
* The foreign key of the target model defined in the through model, e.g. Order#sellerId
|
|
94
|
+
*/
|
|
95
|
+
keyTo: string;
|
|
96
|
+
};
|
|
54
97
|
}
|
|
55
98
|
export interface BelongsToDefinition extends RelationDefinitionBase {
|
|
56
99
|
type: RelationType.belongsTo;
|
|
@@ -62,18 +105,22 @@ export interface HasOneDefinition extends RelationDefinitionBase {
|
|
|
62
105
|
type: RelationType.hasOne;
|
|
63
106
|
targetsMany: false;
|
|
64
107
|
/**
|
|
65
|
-
* The foreign key used by the target model.
|
|
108
|
+
* keyTo: The foreign key used by the target model for this relation.
|
|
109
|
+
* keyFrom: The source key used by the source model for this relation.
|
|
66
110
|
*
|
|
67
111
|
* E.g. when a Customer has one Address instance, then keyTo is "customerId".
|
|
68
112
|
* Note that "customerId" is the default FK assumed by the framework, users
|
|
69
113
|
* can provide a custom FK name by setting "keyTo".
|
|
114
|
+
* And Customer.id is keyFrom. keyFrom defaults to the id property of a model.
|
|
115
|
+
* Users can provide a custom source key name by setting "keyTo".
|
|
70
116
|
*/
|
|
71
117
|
keyTo?: string;
|
|
118
|
+
keyFrom?: string;
|
|
72
119
|
}
|
|
73
120
|
/**
|
|
74
121
|
* A union type describing all possible Relation metadata objects.
|
|
75
122
|
*/
|
|
76
|
-
export declare type RelationMetadata = HasManyDefinition | BelongsToDefinition | HasOneDefinition | RelationDefinitionBase;
|
|
123
|
+
export declare type RelationMetadata = HasManyDefinition | HasManyThroughDefinition | BelongsToDefinition | HasOneDefinition | RelationDefinitionBase;
|
|
77
124
|
export { Getter } from '@loopback/context';
|
|
78
125
|
/**
|
|
79
126
|
* @returns An array of resolved values, the items must be ordered in the same
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relation.types.js","sourceRoot":"","sources":["../../src/relations/relation.types.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;AAOhE,IAAY,YAQX;AARD,WAAY,YAAY;IACtB,uCAAuB,CAAA;IACvB,iCAAiB,CAAA;IACjB,mCAAmB,CAAA;IACnB,uCAAuB,CAAA;IACvB,yCAAyB,CAAA;IACzB,+CAA+B,CAAA;IAC/B,iDAAiC,CAAA;AACnC,CAAC,EARW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAQvB;
|
|
1
|
+
{"version":3,"file":"relation.types.js","sourceRoot":"","sources":["../../src/relations/relation.types.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;AAOhE,IAAY,YAQX;AARD,WAAY,YAAY;IACtB,uCAAuB,CAAA;IACvB,iCAAiB,CAAA;IACjB,mCAAmB,CAAA;IACnB,uCAAuB,CAAA;IACvB,yCAAyB,CAAA;IACzB,+CAA+B,CAAA;IAC/B,iDAAiC,CAAA;AACnC,CAAC,EARW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAQvB;AAkJD,6EAA6E;AAC7E,6CAAyC;AAAjC,2BAAA,MAAM,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import legacy from 'loopback-datasource-juggler';
|
|
2
|
+
import { DataObject, Options } from '../common-types';
|
|
3
3
|
import { Entity } from '../model';
|
|
4
|
-
import {
|
|
4
|
+
import { KeyValueFilter, KeyValueRepository } from './kv.repository';
|
|
5
5
|
import { juggler } from './legacy-juggler-bridge';
|
|
6
6
|
/**
|
|
7
7
|
* An implementation of KeyValueRepository based on loopback-datasource-juggler
|
|
@@ -76,7 +76,7 @@ class AsyncKeyIteratorImpl {
|
|
|
76
76
|
next() {
|
|
77
77
|
const key = legacy_juggler_bridge_1.ensurePromise(this.keys.next());
|
|
78
78
|
return key.then(k => {
|
|
79
|
-
return { done: k === undefined, value: k
|
|
79
|
+
return { done: k === undefined, value: (k !== null && k !== void 0 ? k : '') };
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kv.repository.bridge.js","sourceRoot":"","sources":["../../src/repositories/kv.repository.bridge.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;
|
|
1
|
+
{"version":3,"file":"kv.repository.bridge.js","sourceRoot":"","sources":["../../src/repositories/kv.repository.bridge.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;AAMhE,mEAA+D;AAE/D;;;GAGG;AACH,8DAA8D;AAC9D,IAAI,CAAE,MAAc,CAAC,aAAa,EAAE;IAClC,8DAA8D;IAC7D,MAAc,CAAC,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;CACpE;AAED;;GAEG;AACH,MAAa,yBAAyB;IAOpC;;;OAGG;IACH,YACU,WAA2C,EACnD,EAAsB;QADd,gBAAW,GAAX,WAAW,CAAgC;QAGnD,4EAA4E;QAC5E,gBAAgB;QAChB,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC,WAAW,CAChC,UAAU,CACX,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,GAAW,EAAE,OAAi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AC,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;IACpE,CAAC;IAED,IAAI,CAAC,MAAuB,EAAE,OAAiB;QAC7C,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;QACvC,MAAM,QAAQ,GAAG;YACf,CAAC,MAAM,CAAC,aAAa,CAAC;gBACpB,OAAO,IAAI,oBAAoB,CAC7B,YAAY,CAAC,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAC1C,CAAC;YACJ,CAAC;SACF,CAAC;QACF,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAvED,8DAuEC;AAED,MAAM,oBAAoB;IACxB,YAAoB,IAA6B;QAA7B,SAAI,GAAJ,IAAI,CAAyB;IAAG,CAAC;IACrD,IAAI;QACF,MAAM,GAAG,GAAG,qCAAa,CAAqB,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QAChE,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;YAClB,OAAO,EAAC,IAAI,EAAE,CAAC,KAAK,SAAS,EAAE,KAAK,GAAE,CAAC,aAAD,CAAC,cAAD,CAAC,GAAI,EAAE,CAAA,EAAC,CAAC;QACjD,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Getter } from '@loopback/context';
|
|
2
|
-
import
|
|
2
|
+
import legacy from 'loopback-datasource-juggler';
|
|
3
3
|
import { AnyObject, Command, Count, DataObject, NamedParameters, Options, PositionalParameters } from '../common-types';
|
|
4
4
|
import { Entity } from '../model';
|
|
5
5
|
import { Filter, Inclusion, Where } from '../query';
|
|
@@ -155,6 +155,25 @@ export declare class DefaultCrudRepository<T extends Entity, ID, Relations exten
|
|
|
155
155
|
* @param options - Options for the operations
|
|
156
156
|
*/
|
|
157
157
|
protected includeRelatedModels(entities: T[], include?: Inclusion<T>[], options?: Options): Promise<(T & Relations)[]>;
|
|
158
|
+
/**
|
|
159
|
+
* This function works as a persist hook.
|
|
160
|
+
* It converts an entity from the CRUD operations' caller
|
|
161
|
+
* to a persistable data that can will be stored in the
|
|
162
|
+
* back-end database.
|
|
163
|
+
*
|
|
164
|
+
* User can extend `DefaultCrudRepository` then override this
|
|
165
|
+
* function to execute custom persist hook.
|
|
166
|
+
* @param entity The entity passed from CRUD operations' caller.
|
|
167
|
+
* @param options
|
|
168
|
+
*/
|
|
169
|
+
protected entityToData<R extends T>(entity: R | DataObject<R>, options?: {}): Promise<legacy.ModelData<legacy.PersistedModel>>;
|
|
170
|
+
/** Converts an entity object to a JSON object to check if it contains navigational property.
|
|
171
|
+
* Throws an error if `entity` contains navigational property.
|
|
172
|
+
*
|
|
173
|
+
* @param entity The entity passed from CRUD operations' caller.
|
|
174
|
+
* @param options
|
|
175
|
+
*/
|
|
176
|
+
protected ensurePersistable<R extends T>(entity: R | DataObject<R>, options?: {}): legacy.ModelData<legacy.PersistedModel>;
|
|
158
177
|
/**
|
|
159
178
|
* Removes juggler's "include" filter as it does not apply to LoopBack 4
|
|
160
179
|
* relations.
|