@loopback/repository 2.6.0 → 2.10.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 +63 -0
- package/README.md +1 -1
- package/dist/decorators/metadata.d.ts +1 -1
- package/dist/decorators/metadata.js +6 -6
- package/dist/decorators/metadata.js.map +1 -1
- package/dist/decorators/model.decorator.d.ts +1 -1
- package/dist/decorators/model.decorator.js +10 -10
- package/dist/decorators/model.decorator.js.map +1 -1
- package/dist/decorators/repository.decorator.js +4 -4
- package/dist/decorators/repository.decorator.js.map +1 -1
- package/dist/define-model-class.d.ts +2 -2
- package/dist/mixins/repository.mixin.d.ts +23 -12
- package/dist/mixins/repository.mixin.js +13 -7
- package/dist/mixins/repository.mixin.js.map +1 -1
- package/dist/model.d.ts +19 -2
- package/dist/model.js +46 -2
- package/dist/model.js.map +1 -1
- package/dist/query.d.ts +30 -0
- package/dist/query.js +50 -0
- package/dist/query.js.map +1 -1
- package/dist/relations/belongs-to/belongs-to.decorator.js +2 -2
- package/dist/relations/belongs-to/belongs-to.decorator.js.map +1 -1
- package/dist/relations/belongs-to/belongs-to.helpers.d.ts +1 -0
- package/dist/relations/belongs-to/belongs-to.helpers.js +13 -6
- package/dist/relations/belongs-to/belongs-to.helpers.js.map +1 -1
- package/dist/relations/belongs-to/belongs-to.repository.d.ts +1 -1
- package/dist/relations/has-many/has-many-through-repository.factory.d.ts +11 -0
- package/dist/relations/has-many/has-many-through-repository.factory.js +31 -0
- package/dist/relations/has-many/has-many-through-repository.factory.js.map +1 -0
- package/dist/relations/has-many/has-many-through.helpers.d.ts +122 -14
- package/dist/relations/has-many/has-many-through.helpers.js +153 -20
- package/dist/relations/has-many/has-many-through.helpers.js.map +1 -1
- package/dist/relations/has-many/has-many-through.repository.d.ts +39 -2
- package/dist/relations/has-many/has-many-through.repository.js +87 -0
- package/dist/relations/has-many/has-many-through.repository.js.map +1 -1
- package/dist/relations/has-many/has-many.helpers.js +2 -1
- package/dist/relations/has-many/has-many.helpers.js.map +1 -1
- package/dist/relations/has-many/has-many.repository.d.ts +1 -1
- package/dist/relations/has-many/index.d.ts +4 -2
- package/dist/relations/has-many/index.js +4 -2
- package/dist/relations/has-many/index.js.map +1 -1
- package/dist/relations/has-one/has-one.helpers.js +2 -1
- package/dist/relations/has-one/has-one.helpers.js.map +1 -1
- package/dist/relations/has-one/has-one.repository.d.ts +1 -1
- package/dist/relations/relation.decorator.js +6 -6
- package/dist/relations/relation.decorator.js.map +1 -1
- package/dist/relations/relation.types.d.ts +2 -2
- package/dist/relations/relation.types.js +2 -2
- package/dist/relations/relation.types.js.map +1 -1
- package/dist/repositories/constraint-utils.d.ts +10 -0
- package/dist/repositories/constraint-utils.js +16 -1
- package/dist/repositories/constraint-utils.js.map +1 -1
- package/dist/repositories/legacy-juggler-bridge.d.ts +33 -2
- package/dist/repositories/legacy-juggler-bridge.js +34 -0
- package/dist/repositories/legacy-juggler-bridge.js.map +1 -1
- package/package.json +15 -13
- package/src/decorators/metadata.ts +1 -1
- package/src/decorators/model.decorator.ts +1 -1
- package/src/decorators/repository.decorator.ts +1 -1
- package/src/define-model-class.ts +2 -2
- package/src/mixins/repository.mixin.ts +8 -2
- package/src/model.ts +64 -4
- package/src/query.ts +55 -0
- package/src/relations/belongs-to/belongs-to.decorator.ts +1 -1
- package/src/relations/belongs-to/belongs-to.helpers.ts +19 -8
- package/src/relations/belongs-to/belongs-to.repository.ts +1 -1
- package/src/relations/has-many/has-many-through-repository.factory.ts +104 -0
- package/src/relations/has-many/has-many-through.helpers.ts +182 -21
- package/src/relations/has-many/has-many-through.repository.ts +191 -2
- package/src/relations/has-many/has-many.helpers.ts +1 -2
- package/src/relations/has-many/has-many.repository.ts +1 -1
- package/src/relations/has-many/index.ts +4 -2
- package/src/relations/has-one/has-one.helpers.ts +1 -2
- package/src/relations/has-one/has-one.repository.ts +1 -1
- package/src/relations/relation.decorator.ts +1 -1
- package/src/relations/relation.types.ts +2 -2
- package/src/repositories/constraint-utils.ts +17 -0
- package/src/repositories/legacy-juggler-bridge.ts +59 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,69 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [2.10.0](https://github.com/strongloop/loopback-next/compare/@loopback/repository@2.9.0...@loopback/repository@2.10.0) (2020-07-20)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **repository:** hasManyThrough can delete correct target n through based on filter ([c1ba91f](https://github.com/strongloop/loopback-next/commit/c1ba91f2dcbc33dd1cee905d25f9719a71bc7919))
|
|
12
|
+
* ensure delete only applies to optional properties ([89cd43f](https://github.com/strongloop/loopback-next/commit/89cd43f1a455983f120d9bb9c869eac36adc7ad7))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* **repository:** add helpers to create relations ([42d17aa](https://github.com/strongloop/loopback-next/commit/42d17aa37fa88bb4c4152b26450ddb8b72da1f49))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# [2.9.0](https://github.com/strongloop/loopback-next/compare/@loopback/repository@2.8.0...@loopback/repository@2.9.0) (2020-06-30)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Features
|
|
27
|
+
|
|
28
|
+
* add HasManyThroughFactory to Juggler bridge ([c2d4352](https://github.com/strongloop/loopback-next/commit/c2d43524be4fd1345970b29e722e57890f2ea766))
|
|
29
|
+
* **repository:** add link and unlink methods ([31dc4e9](https://github.com/strongloop/loopback-next/commit/31dc4e989ae981732fa43f7f48dfb8f19d5ac796))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
# [2.8.0](https://github.com/strongloop/loopback-next/compare/@loopback/repository@2.7.0...@loopback/repository@2.8.0) (2020-06-23)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
### Bug Fixes
|
|
39
|
+
|
|
40
|
+
* set node version to >=10.16 to support events.once ([e39da1c](https://github.com/strongloop/loopback-next/commit/e39da1ca47728eafaf83c10ce35b09b03b6a4edc))
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
### Features
|
|
44
|
+
|
|
45
|
+
* **repository:** implement hasManyThrough repo ([ecd2780](https://github.com/strongloop/loopback-next/commit/ecd2780c034e902e72905f0bbefe3a6fe08c3a2c))
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
# [2.7.0](https://github.com/strongloop/loopback-next/compare/@loopback/repository@2.6.0...@loopback/repository@2.7.0) (2020-06-11)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
### Bug Fixes
|
|
55
|
+
|
|
56
|
+
* **repository:** fix DynamicModelCtor type to correctly preserve Props ([927789e](https://github.com/strongloop/loopback-next/commit/927789e254f4db7945201609683ae83a18f1c48d))
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
### Features
|
|
60
|
+
|
|
61
|
+
* **repository:** add hasManyThrough factory and tests ([3304963](https://github.com/strongloop/loopback-next/commit/33049634e2320cd30e5f9403e03db17000dd49cd))
|
|
62
|
+
* **repository:** add more helpers for HasManyThrough ([c795544](https://github.com/strongloop/loopback-next/commit/c7955446c38b2dfd0d064eb6fa4d90a7f76283a2))
|
|
63
|
+
* **repository:** adds fuzzy where filters to WhereBuilder ([7f79805](https://github.com/strongloop/loopback-next/commit/7f798052b33077b12ae2becb5c42453800aa54aa)), closes [#5577](https://github.com/strongloop/loopback-next/issues/5577)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
6
69
|
# [2.6.0](https://github.com/strongloop/loopback-next/compare/@loopback/repository@2.5.1...@loopback/repository@2.6.0) (2020-05-28)
|
|
7
70
|
|
|
8
71
|
|
package/README.md
CHANGED
|
@@ -97,7 +97,7 @@ or properties.
|
|
|
97
97
|
import {repository} from '@loopback/repository';
|
|
98
98
|
import {NoteRepository} from '../repositories';
|
|
99
99
|
import {Note} from '../models';
|
|
100
|
-
import {post, requestBody, get, param} from '@loopback/
|
|
100
|
+
import {post, requestBody, get, param} from '@loopback/rest';
|
|
101
101
|
|
|
102
102
|
export class NoteController {
|
|
103
103
|
constructor(
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.ModelMetadataHelper = void 0;
|
|
8
|
-
const
|
|
8
|
+
const core_1 = require("@loopback/core");
|
|
9
9
|
const model_1 = require("../model");
|
|
10
10
|
const relations_1 = require("../relations");
|
|
11
11
|
const model_decorator_1 = require("./model.decorator");
|
|
@@ -18,7 +18,7 @@ class ModelMetadataHelper {
|
|
|
18
18
|
* the output of the metadata retrieval functions.
|
|
19
19
|
*/
|
|
20
20
|
static getModelMetadata(target, options) {
|
|
21
|
-
const classDef =
|
|
21
|
+
const classDef = core_1.MetadataInspector.getClassMetadata(model_decorator_1.MODEL_WITH_PROPERTIES_KEY, target,
|
|
22
22
|
// https://github.com/strongloop/loopback-next/issues/4721
|
|
23
23
|
// The `target` can be a subclass for a base model
|
|
24
24
|
{ ...options, ownMetadataOnly: true });
|
|
@@ -29,7 +29,7 @@ class ModelMetadataHelper {
|
|
|
29
29
|
return classDef;
|
|
30
30
|
}
|
|
31
31
|
else {
|
|
32
|
-
const modelMeta =
|
|
32
|
+
const modelMeta = core_1.MetadataInspector.getClassMetadata(model_decorator_1.MODEL_KEY, target, options);
|
|
33
33
|
if (!modelMeta) {
|
|
34
34
|
return {};
|
|
35
35
|
}
|
|
@@ -39,9 +39,9 @@ class ModelMetadataHelper {
|
|
|
39
39
|
const meta = new model_1.ModelDefinition(Object.assign({}, modelMeta));
|
|
40
40
|
// set properties lost from creating instance of ModelDefinition
|
|
41
41
|
Object.assign(meta, modelMeta);
|
|
42
|
-
meta.properties = Object.assign({},
|
|
43
|
-
meta.relations = Object.assign({},
|
|
44
|
-
|
|
42
|
+
meta.properties = Object.assign({}, core_1.MetadataInspector.getAllPropertyMetadata(model_decorator_1.MODEL_PROPERTIES_KEY, target.prototype, options));
|
|
43
|
+
meta.relations = Object.assign({}, core_1.MetadataInspector.getAllPropertyMetadata(relations_1.RELATIONS_KEY, target.prototype, options));
|
|
44
|
+
core_1.MetadataInspector.defineMetadata(model_decorator_1.MODEL_WITH_PROPERTIES_KEY.key, meta, target);
|
|
45
45
|
return meta;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../src/decorators/metadata.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;AAEhE
|
|
1
|
+
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../src/decorators/metadata.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;AAEhE,yCAAoE;AACpE,oCAAgE;AAChE,4CAA2C;AAC3C,uDAK2B;AAE3B,MAAa,mBAAmB;IAC9B;;;;;;OAMG;IACH,MAAM,CAAC,gBAAgB,CACrB,MAAgB,EAChB,OAA2B;QAE3B,MAAM,QAAQ,GAAG,wBAAiB,CAAC,gBAAgB,CACjD,2CAAyB,EACzB,MAAM;QACN,0DAA0D;QAC1D,kDAAkD;QAClD,EAAC,GAAG,OAAO,EAAE,eAAe,EAAE,IAAI,EAAC,CACpC,CAAC;QACF,yCAAyC;QACzC,uEAAuE;QACvE,iEAAiE;QACjE,IAAI,QAAQ,EAAE;YACZ,OAAO,QAAQ,CAAC;SACjB;aAAM;YACL,MAAM,SAAS,GAAG,wBAAiB,CAAC,gBAAgB,CAClD,2BAAS,EACT,MAAM,EACN,OAAO,CACR,CAAC;YACF,IAAI,CAAC,SAAS,EAAE;gBACd,OAAO,EAAE,CAAC;aACX;iBAAM;gBACL,sEAAsE;gBAEtE,6DAA6D;gBAC7D,MAAM,IAAI,GAAG,IAAI,uBAAe,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC;gBAE/D,gEAAgE;gBAChE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;gBAE/B,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,MAAM,CAChB,EAAE,EACf,wBAAiB,CAAC,sBAAsB,CACtC,sCAAoB,EACpB,MAAM,CAAC,SAAS,EAChB,OAAO,CACR,CACF,CAAC;gBAEF,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CACL,EAAE,EACzB,wBAAiB,CAAC,sBAAsB,CACtC,yBAAa,EACb,MAAM,CAAC,SAAS,EAChB,OAAO,CACR,CACF,CAAC;gBAEF,wBAAiB,CAAC,cAAc,CAC9B,2CAAyB,CAAC,GAAG,EAC7B,IAAI,EACJ,MAAM,CACP,CAAC;gBACF,OAAO,IAAI,CAAC;aACb;SACF;IACH,CAAC;CACF;AApED,kDAoEC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MetadataAccessor, MetadataMap } from '@loopback/
|
|
1
|
+
import { MetadataAccessor, MetadataMap } from '@loopback/core';
|
|
2
2
|
import { ModelDefinition, ModelDefinitionSyntax, PropertyDefinition, PropertyType } from '../model';
|
|
3
3
|
export declare const MODEL_KEY: MetadataAccessor<Partial<ModelDefinitionSyntax>, ClassDecorator>;
|
|
4
4
|
export declare const MODEL_PROPERTIES_KEY: MetadataAccessor<PropertyDefinition, PropertyDecorator>;
|
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.property = exports.buildModelDefinition = exports.model = exports.MODEL_WITH_PROPERTIES_KEY = exports.MODEL_PROPERTIES_KEY = exports.MODEL_KEY = void 0;
|
|
8
|
-
const
|
|
8
|
+
const core_1 = require("@loopback/core");
|
|
9
9
|
const model_1 = require("../model");
|
|
10
10
|
const relation_decorator_1 = require("../relations/relation.decorator");
|
|
11
|
-
exports.MODEL_KEY =
|
|
12
|
-
exports.MODEL_PROPERTIES_KEY =
|
|
13
|
-
exports.MODEL_WITH_PROPERTIES_KEY =
|
|
11
|
+
exports.MODEL_KEY = core_1.MetadataAccessor.create('loopback:model');
|
|
12
|
+
exports.MODEL_PROPERTIES_KEY = core_1.MetadataAccessor.create('loopback:model-properties');
|
|
13
|
+
exports.MODEL_WITH_PROPERTIES_KEY = core_1.MetadataAccessor.create('loopback:model-and-properties');
|
|
14
14
|
/**
|
|
15
15
|
* Decorator for model definitions
|
|
16
16
|
* @param definition
|
|
@@ -23,7 +23,7 @@ function model(definition) {
|
|
|
23
23
|
const def = Object.assign(definition, {
|
|
24
24
|
name: (_a = definition.name) !== null && _a !== void 0 ? _a : target.name,
|
|
25
25
|
});
|
|
26
|
-
const decorator =
|
|
26
|
+
const decorator = core_1.ClassDecoratorFactory.createDecorator(exports.MODEL_KEY, definition, { decoratorName: '@model' });
|
|
27
27
|
decorator(target);
|
|
28
28
|
// Build "ModelDefinition" and store it on model constructor
|
|
29
29
|
buildModelDefinition(target, def);
|
|
@@ -48,17 +48,17 @@ function buildModelDefinition(target, def) {
|
|
|
48
48
|
}
|
|
49
49
|
const modelDef = new model_1.ModelDefinition(def !== null && def !== void 0 ? def : { name: target.name });
|
|
50
50
|
const prototype = target.prototype;
|
|
51
|
-
const propertyMap = (_a =
|
|
51
|
+
const propertyMap = (_a = core_1.MetadataInspector.getAllPropertyMetadata(exports.MODEL_PROPERTIES_KEY, prototype)) !== null && _a !== void 0 ? _a : {};
|
|
52
52
|
for (const p in propertyMap) {
|
|
53
53
|
const propertyDef = propertyMap[p];
|
|
54
|
-
const designType =
|
|
54
|
+
const designType = core_1.MetadataInspector.getDesignTypeForProperty(prototype, p);
|
|
55
55
|
if (!propertyDef.type) {
|
|
56
56
|
propertyDef.type = designType;
|
|
57
57
|
}
|
|
58
58
|
modelDef.addProperty(p, propertyDef);
|
|
59
59
|
}
|
|
60
60
|
target.definition = modelDef;
|
|
61
|
-
const relationMeta = (_b =
|
|
61
|
+
const relationMeta = (_b = core_1.MetadataInspector.getAllPropertyMetadata(relation_decorator_1.RELATIONS_KEY, prototype)) !== null && _b !== void 0 ? _b : {};
|
|
62
62
|
const relations = {};
|
|
63
63
|
// Build an object keyed by relation names
|
|
64
64
|
Object.values(relationMeta).forEach(r => {
|
|
@@ -74,7 +74,7 @@ exports.buildModelDefinition = buildModelDefinition;
|
|
|
74
74
|
* @returns A property decorator
|
|
75
75
|
*/
|
|
76
76
|
function property(definition) {
|
|
77
|
-
return
|
|
77
|
+
return core_1.PropertyDecoratorFactory.createDecorator(exports.MODEL_PROPERTIES_KEY, Object.assign({}, definition), { decoratorName: '@property' });
|
|
78
78
|
}
|
|
79
79
|
exports.property = property;
|
|
80
80
|
(function (property) {
|
|
@@ -89,7 +89,7 @@ exports.property = property;
|
|
|
89
89
|
*/
|
|
90
90
|
function array(itemType, definition) {
|
|
91
91
|
return function (target, propertyName) {
|
|
92
|
-
const propType =
|
|
92
|
+
const propType = core_1.MetadataInspector.getDesignTypeForProperty(target, propertyName);
|
|
93
93
|
if (propType !== Array) {
|
|
94
94
|
throw new Error(property.ERR_PROP_NOT_ARRAY);
|
|
95
95
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.decorator.js","sourceRoot":"","sources":["../../src/decorators/model.decorator.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;AAEhE
|
|
1
|
+
{"version":3,"file":"model.decorator.js","sourceRoot":"","sources":["../../src/decorators/model.decorator.ts"],"names":[],"mappings":";AAAA,sDAAsD;AAC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C;AAND,4BAMC;AAED,WAAiB,QAAQ;IACV,2BAAkB,GAC7B,qDAAqD,CAAC;IAC3C,oBAAW,GAAG,6CAA6C,CAAC;IAEzE;;;;;;OAMG;IACH,SAAgB,KAAK,CACnB,QAAsB,EACtB,UAAwC;QAExC,OAAO,UAAU,MAAc,EAAE,YAAoB;YACnD,MAAM,QAAQ,GAAG,wBAAiB,CAAC,wBAAwB,CACzD,MAAM,EACN,YAAY,CACb,CAAC;YACF,IAAI,QAAQ,KAAK,KAAK,EAAE;gBACtB,MAAM,IAAI,KAAK,CAAC,SAAA,kBAAkB,CAAC,CAAC;aACrC;iBAAM;gBACL,QAAQ,CACN,MAAM,CAAC,MAAM,CACX,EAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAgC,EACtD,UAAU,CACX,CACF,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;aACzB;QACH,CAAC,CAAC;IACJ,CAAC;IApBe,cAAK,QAoBpB,CAAA;AACH,CAAC,EAjCgB,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAiCxB"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.repository = exports.RepositoryMetadata = void 0;
|
|
8
8
|
const tslib_1 = require("tslib");
|
|
9
|
-
const
|
|
9
|
+
const core_1 = require("@loopback/core");
|
|
10
10
|
const assert_1 = tslib_1.__importDefault(require("assert"));
|
|
11
11
|
const repositories_1 = require("../repositories");
|
|
12
12
|
const legacy_juggler_bridge_1 = require("../repositories/legacy-juggler-bridge");
|
|
@@ -63,11 +63,11 @@ function repository(modelOrRepo, dataSource) {
|
|
|
63
63
|
// Please note key is undefined for constructor. If strictNullChecks
|
|
64
64
|
// is true, the compiler will complain as reflect-metadata won't
|
|
65
65
|
// accept undefined or null for key. Use ! to fool the compiler.
|
|
66
|
-
|
|
66
|
+
core_1.inject('repositories.' + meta.name, meta)(target, key, descriptorOrIndex);
|
|
67
67
|
}
|
|
68
68
|
else {
|
|
69
69
|
// Use repository-factory to create a repository from model + dataSource
|
|
70
|
-
|
|
70
|
+
core_1.inject('', meta, resolve)(target, key, descriptorOrIndex);
|
|
71
71
|
}
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
@@ -85,7 +85,7 @@ exports.repository = repository;
|
|
|
85
85
|
*/
|
|
86
86
|
function getter(nameOrClass) {
|
|
87
87
|
const name = typeof nameOrClass === 'string' ? nameOrClass : nameOrClass.name;
|
|
88
|
-
return
|
|
88
|
+
return core_1.inject.getter(`repositories.${name}`);
|
|
89
89
|
}
|
|
90
90
|
repository.getter = getter;
|
|
91
91
|
})(repository = exports.repository || (exports.repository = {}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.decorator.js","sourceRoot":"","sources":["../../src/decorators/repository.decorator.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;;AAEhE
|
|
1
|
+
{"version":3,"file":"repository.decorator.js","sourceRoot":"","sources":["../../src/decorators/repository.decorator.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,yCAA0D;AAC1D,4DAA4B;AAI5B,kDAAkE;AAClE,iFAA8D;AAY9D;;GAEG;AACH,MAAa,kBAAkB;IAsB7B;;;;;;;;;;;;;;;OAeG;IACH,YACE,WAAmC,EACnC,UAAqD;QAErD,IAAI,CAAC,IAAI;YACP,OAAO,WAAW,KAAK,QAAQ,IAAI,UAAU,KAAK,SAAS;gBACzD,CAAC,CAAC,WAAW;gBACb,CAAC,CAAC,SAAS,CAAC;QAChB,IAAI,CAAC,SAAS;YACZ,OAAO,WAAW,KAAK,QAAQ,IAAI,UAAU,IAAI,IAAI;gBACnD,CAAC,CAAC,WAAW;gBACb,CAAC,CAAC,SAAS,CAAC;QAChB,IAAI,CAAC,UAAU;YACb,OAAO,WAAW,KAAK,UAAU,CAA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,UAAU;IACzB;;;;;OAKG;IACH,SAAgB,MAAM,CAAC,WAA8C;QACnE,MAAM,IAAI,GACR,OAAO,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC;QACnE,OAAO,aAAM,CAAC,MAAM,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAC;IAC/C,CAAC;IAJe,iBAAM,SAIrB,CAAA;AACH,CAAC,EAZgB,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAY1B;AAED;;;;GAIG;AACH,KAAK,UAAU,OAAO,CAAC,GAAY,EAAE,SAAoB;IACvD,MAAM,IAAI,GAAG,SAAS,CAAC,QAA8B,CAAC;IACtD,IAAI,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;IACjC,IAAI,IAAI,CAAC,SAAS,EAAE;QAClB,UAAU,GAAG,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,CAAkB,CAAC;KAC3E;IACD,IAAI,CAAC,UAAU,EAAE;QACf,MAAM,IAAI,KAAK,CACb,6BAA6B;YAC3B,kDAAkD,CACrD,CAAC;KACH;IAED,IAAI,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;IACjC,IAAI,IAAI,CAAC,cAAc,EAAE;QACvB,UAAU,GAAG,MAAM,GAAG,CAAC,GAAG,CACxB,cAAc,GAAG,IAAI,CAAC,cAAc,CACrC,CAAC;KACH;IACD,gBAAM,CACJ,UAAU,YAAY,+BAAO,CAAC,UAAU,EACxC,6BAA6B,CAC9B,CAAC;IACF,OAAO,IAAI,oCAAqB,CAC9B,UAAU,EACV,UAAiC,CAClC,CAAC;AACJ,CAAC"}
|
|
@@ -49,7 +49,7 @@ export declare function defineModelClass<BaseCtor extends typeof Model, Props ex
|
|
|
49
49
|
* - all prototype fields from `BaseCtor` prototype are inherited and available
|
|
50
50
|
* as prototype fields on the dynamic class
|
|
51
51
|
*/
|
|
52
|
-
export declare type DynamicModelCtor<BaseCtor extends typeof Model, Props extends object> =
|
|
52
|
+
export declare type DynamicModelCtor<BaseCtor extends typeof Model, Props extends object> = {
|
|
53
53
|
/** Model constructor accepting partial model data. */
|
|
54
54
|
new (data?: DataObject<PrototypeOf<BaseCtor> & Props>): PrototypeOf<BaseCtor> & Props;
|
|
55
|
-
};
|
|
55
|
+
} & BaseCtor;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { Binding, BindingFromClassOptions } from '@loopback/
|
|
1
|
+
import { Binding, BindingFromClassOptions } from '@loopback/core';
|
|
2
2
|
import { Application, Component, Constructor, MixinTarget } from '@loopback/core';
|
|
3
3
|
import { Class } from '../common-types';
|
|
4
4
|
import { SchemaMigrationOptions } from '../datasource';
|
|
5
5
|
import { Model } from '../model';
|
|
6
6
|
import { juggler, Repository } from '../repositories';
|
|
7
|
-
import * as loopbackContext from '@loopback/
|
|
8
|
-
import * as loopbackCore from '@loopback/core';
|
|
7
|
+
import * as loopbackContext from '@loopback/core';
|
|
9
8
|
/**
|
|
10
9
|
* A mixin class for Application that creates a .repository()
|
|
11
10
|
* function to register a repository automatically. Also overrides
|
|
@@ -19,6 +18,12 @@ import * as loopbackCore from '@loopback/core';
|
|
|
19
18
|
* Please note: the members in the mixin function are documented in a dummy class
|
|
20
19
|
* called <a href="#RepositoryMixinDoc">RepositoryMixinDoc</a>
|
|
21
20
|
*
|
|
21
|
+
* @param superClass - Application class
|
|
22
|
+
* @returns A new class that extends the super class with repository related
|
|
23
|
+
* methods
|
|
24
|
+
*
|
|
25
|
+
* @typeParam T - Type of the application class as the target for the mixin
|
|
26
|
+
*
|
|
22
27
|
*/
|
|
23
28
|
export declare function RepositoryMixin<T extends MixinTarget<Application>>(superClass: T): {
|
|
24
29
|
new (...args: any[]): {
|
|
@@ -143,17 +148,17 @@ export declare function RepositoryMixin<T extends MixinTarget<Application>>(supe
|
|
|
143
148
|
* preserving data or rebuild everything from scratch.
|
|
144
149
|
*/
|
|
145
150
|
migrateSchema(options?: SchemaMigrationOptions): Promise<void>;
|
|
146
|
-
readonly options:
|
|
151
|
+
readonly options: loopbackContext.ApplicationConfig;
|
|
147
152
|
readonly state: string;
|
|
148
153
|
controller: <T_1>(controllerCtor: Constructor<T_1>, nameOrOptions?: string | BindingFromClassOptions | undefined) => Binding<T_1>;
|
|
149
|
-
server: <T_2 extends
|
|
150
|
-
servers: <T_3 extends
|
|
151
|
-
getServer: <T_4 extends
|
|
154
|
+
server: <T_2 extends loopbackContext.Server>(ctor: Constructor<T_2>, nameOrOptions?: string | BindingFromClassOptions | undefined) => Binding<T_2>;
|
|
155
|
+
servers: <T_3 extends loopbackContext.Server>(ctors: Constructor<T_3>[]) => Binding<any>[];
|
|
156
|
+
getServer: <T_4 extends loopbackContext.Server>(target: string | Constructor<T_4>) => Promise<T_4>;
|
|
152
157
|
start: () => Promise<void>;
|
|
153
158
|
stop: () => Promise<void>;
|
|
154
|
-
setMetadata: (metadata:
|
|
155
|
-
lifeCycleObserver: <T_5 extends
|
|
156
|
-
service: <S>(cls: Constructor<S | loopbackContext.Provider<S>>, nameOrOptions?: string |
|
|
159
|
+
setMetadata: (metadata: loopbackContext.ApplicationMetadata) => void;
|
|
160
|
+
lifeCycleObserver: <T_5 extends loopbackContext.LifeCycleObserver>(ctor: Constructor<T_5>, nameOrOptions?: string | BindingFromClassOptions | undefined) => Binding<T_5>;
|
|
161
|
+
service: <S>(cls: Constructor<S | loopbackContext.Provider<S>>, nameOrOptions?: string | loopbackContext.ServiceOptions | undefined) => Binding<S>;
|
|
157
162
|
interceptor: (interceptor: loopbackContext.Interceptor | Constructor<loopbackContext.Provider<loopbackContext.Interceptor>>, nameOrOptions?: string | loopbackContext.InterceptorBindingOptions | undefined) => Binding<loopbackContext.Interceptor>;
|
|
158
163
|
readonly name: string;
|
|
159
164
|
readonly subscriptionManager: loopbackContext.ContextSubscriptionManager;
|
|
@@ -195,9 +200,15 @@ export declare function RepositoryMixin<T extends MixinTarget<Application>>(supe
|
|
|
195
200
|
getValueOrPromise: <ValueType_9>(keyWithPath: loopbackContext.BindingAddress<ValueType_9>, optionsOrSession?: loopbackContext.ResolutionOptions | loopbackContext.ResolutionSession | undefined) => loopbackContext.ValueOrPromise<ValueType_9 | undefined>;
|
|
196
201
|
toJSON: () => loopbackContext.JSONObject;
|
|
197
202
|
inspect: (options?: loopbackContext.ContextInspectOptions | undefined) => loopbackContext.JSONObject;
|
|
203
|
+
on: {
|
|
204
|
+
(eventName: "bind" | "unbind", listener: loopbackContext.ContextEventListener): Application;
|
|
205
|
+
(event: string | symbol, listener: (...args: any[]) => void): Application;
|
|
206
|
+
};
|
|
207
|
+
once: {
|
|
208
|
+
(eventName: "bind" | "unbind", listener: loopbackContext.ContextEventListener): Application;
|
|
209
|
+
(event: string | symbol, listener: (...args: any[]) => void): Application;
|
|
210
|
+
};
|
|
198
211
|
addListener: (event: string | symbol, listener: (...args: any[]) => void) => Application;
|
|
199
|
-
on: (event: string | symbol, listener: (...args: any[]) => void) => Application;
|
|
200
|
-
once: (event: string | symbol, listener: (...args: any[]) => void) => Application;
|
|
201
212
|
prependListener: (event: string | symbol, listener: (...args: any[]) => void) => Application;
|
|
202
213
|
prependOnceListener: (event: string | symbol, listener: (...args: any[]) => void) => Application;
|
|
203
214
|
removeListener: (event: string | symbol, listener: (...args: any[]) => void) => Application;
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.createModelClassBinding = exports.RepositoryMixinDoc = exports.RepositoryMixin = void 0;
|
|
8
8
|
const tslib_1 = require("tslib");
|
|
9
|
-
const context_1 = require("@loopback/context");
|
|
10
9
|
const core_1 = require("@loopback/core");
|
|
10
|
+
const core_2 = require("@loopback/core");
|
|
11
11
|
const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
12
12
|
const keys_1 = require("../keys");
|
|
13
13
|
const repositories_1 = require("../repositories");
|
|
@@ -26,6 +26,12 @@ const debug = debug_1.default('loopback:repository:mixin');
|
|
|
26
26
|
* Please note: the members in the mixin function are documented in a dummy class
|
|
27
27
|
* called <a href="#RepositoryMixinDoc">RepositoryMixinDoc</a>
|
|
28
28
|
*
|
|
29
|
+
* @param superClass - Application class
|
|
30
|
+
* @returns A new class that extends the super class with repository related
|
|
31
|
+
* methods
|
|
32
|
+
*
|
|
33
|
+
* @typeParam T - Type of the application class as the target for the mixin
|
|
34
|
+
*
|
|
29
35
|
*/
|
|
30
36
|
function RepositoryMixin(superClass) {
|
|
31
37
|
return class extends superClass {
|
|
@@ -60,10 +66,10 @@ function RepositoryMixin(superClass) {
|
|
|
60
66
|
*/
|
|
61
67
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
62
68
|
repository(repoClass, nameOrOptions) {
|
|
63
|
-
const binding =
|
|
69
|
+
const binding = core_1.createBindingFromClass(repoClass, {
|
|
64
70
|
namespace: keys_1.RepositoryBindings.REPOSITORIES,
|
|
65
71
|
type: keys_1.RepositoryTags.REPOSITORY,
|
|
66
|
-
defaultScope:
|
|
72
|
+
defaultScope: core_1.BindingScope.TRANSIENT,
|
|
67
73
|
...toOptions(nameOrOptions),
|
|
68
74
|
}).tag(keys_1.RepositoryTags.REPOSITORY);
|
|
69
75
|
this.add(binding);
|
|
@@ -115,10 +121,10 @@ function RepositoryMixin(superClass) {
|
|
|
115
121
|
else if (typeof dataSource === 'function') {
|
|
116
122
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
117
123
|
options.name = options.name || dataSource.dataSourceName;
|
|
118
|
-
const binding =
|
|
124
|
+
const binding = core_1.createBindingFromClass(dataSource, {
|
|
119
125
|
namespace: keys_1.RepositoryBindings.DATASOURCES,
|
|
120
126
|
type: keys_1.RepositoryTags.DATASOURCE,
|
|
121
|
-
defaultScope:
|
|
127
|
+
defaultScope: core_1.BindingScope.SINGLETON,
|
|
122
128
|
...options,
|
|
123
129
|
});
|
|
124
130
|
this.add(binding);
|
|
@@ -198,7 +204,7 @@ function RepositoryMixin(superClass) {
|
|
|
198
204
|
if (typeof componentInstanceOrClass !== 'function')
|
|
199
205
|
return componentInstanceOrClass;
|
|
200
206
|
const componentName = componentInstanceOrClass.name;
|
|
201
|
-
const componentKey = `${
|
|
207
|
+
const componentKey = `${core_2.CoreBindings.COMPONENTS}.${componentName}`;
|
|
202
208
|
return ctx.getSync(componentKey);
|
|
203
209
|
}
|
|
204
210
|
}
|
|
@@ -390,7 +396,7 @@ exports.RepositoryMixinDoc = RepositoryMixinDoc;
|
|
|
390
396
|
* @param modelClass - Model class
|
|
391
397
|
*/
|
|
392
398
|
function createModelClassBinding(modelClass) {
|
|
393
|
-
return
|
|
399
|
+
return core_1.Binding.bind(`${keys_1.RepositoryBindings.MODELS}.${modelClass.name}`)
|
|
394
400
|
.to(modelClass)
|
|
395
401
|
.tag(keys_1.RepositoryTags.MODEL);
|
|
396
402
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.mixin.js","sourceRoot":"","sources":["../../src/mixins/repository.mixin.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;;AAEhE
|
|
1
|
+
{"version":3,"file":"repository.mixin.js","sourceRoot":"","sources":["../../src/mixins/repository.mixin.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,yCAKwB;AACxB,yCAMwB;AACxB,0DAAiC;AAGjC,kCAA2D;AAE3D,kDAAoD;AAEpD,MAAM,KAAK,GAAG,eAAY,CAAC,2BAA2B,CAAC,CAAC;AAMxD,qDAAqD;AAErD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,eAAe,CAC7B,UAAa;IAEb,OAAO,KAAM,SAAQ,UAAU;QAC7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;WA4BG;QACH,8DAA8D;QAC9D,UAAU,CACR,SAAmB,EACnB,aAAgD;Y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G,CAAC;IAEjD;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,aAAa,CAAC,OAAgC,IAAkB,CAAC;CACxE;AAhID,gDAgIC;AAED;;;GAGG;AACH,SAAgB,uBAAuB,CACrC,UAAa;IAEb,OAAO,cAAO,CAAC,IAAI,CAAI,GAAG,yBAAkB,CAAC,MAAM,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC;SACtE,EAAE,CAAC,UAAU,CAAC;SACd,GAAG,CAAC,qBAAc,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC;AAND,0DAMC"}
|
package/dist/model.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AnyObject, DataObject, Options, PrototypeOf } from './common-types';
|
|
2
|
-
import { JsonSchema } from './index';
|
|
3
|
-
import { RelationMetadata } from './relations';
|
|
2
|
+
import { BelongsToDefinition, HasManyDefinition, HasOneDefinition, JsonSchema, RelationMetadata } from './index';
|
|
4
3
|
import { TypeResolver } from './type-resolver';
|
|
5
4
|
import { Type } from './types';
|
|
6
5
|
/**
|
|
@@ -85,6 +84,24 @@ export declare class ModelDefinition {
|
|
|
85
84
|
* @param definition - The definition of the new relation.
|
|
86
85
|
*/
|
|
87
86
|
addRelation(definition: RelationMetadata): this;
|
|
87
|
+
/**
|
|
88
|
+
* Define a new belongsTo relation.
|
|
89
|
+
* @param name - The name of the belongsTo relation.
|
|
90
|
+
* @param definition - The definition of the belongsTo relation.
|
|
91
|
+
*/
|
|
92
|
+
belongsTo(name: string, definition: Omit<BelongsToDefinition, 'name' | 'type' | 'targetsMany'>): this;
|
|
93
|
+
/**
|
|
94
|
+
* Define a new hasOne relation.
|
|
95
|
+
* @param name - The name of the hasOne relation.
|
|
96
|
+
* @param definition - The definition of the hasOne relation.
|
|
97
|
+
*/
|
|
98
|
+
hasOne(name: string, definition: Omit<HasOneDefinition, 'name' | 'type' | 'targetsMany'>): this;
|
|
99
|
+
/**
|
|
100
|
+
* Define a new hasMany relation.
|
|
101
|
+
* @param name - The name of the hasMany relation.
|
|
102
|
+
* @param definition - The definition of the hasMany relation.
|
|
103
|
+
*/
|
|
104
|
+
hasMany(name: string, definition: Omit<HasManyDefinition, 'name' | 'type' | 'targetsMany'>): this;
|
|
88
105
|
/**
|
|
89
106
|
* Get an array of names of ID properties, which are specified in
|
|
90
107
|
* the model settings or properties with `id` attribute.
|
package/dist/model.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.rejectNavigationalPropertiesInData = exports.Event = exports.Entity = exports.ValueObject = exports.Model = exports.ModelDefinition = void 0;
|
|
8
|
+
const index_1 = require("./index");
|
|
8
9
|
/**
|
|
9
10
|
* Definition for a model
|
|
10
11
|
*/
|
|
@@ -59,6 +60,48 @@ class ModelDefinition {
|
|
|
59
60
|
this.relations[definition.name] = definition;
|
|
60
61
|
return this;
|
|
61
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Define a new belongsTo relation.
|
|
65
|
+
* @param name - The name of the belongsTo relation.
|
|
66
|
+
* @param definition - The definition of the belongsTo relation.
|
|
67
|
+
*/
|
|
68
|
+
belongsTo(name, definition) {
|
|
69
|
+
const meta = {
|
|
70
|
+
...definition,
|
|
71
|
+
name,
|
|
72
|
+
type: index_1.RelationType.belongsTo,
|
|
73
|
+
targetsMany: false,
|
|
74
|
+
};
|
|
75
|
+
return this.addRelation(meta);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Define a new hasOne relation.
|
|
79
|
+
* @param name - The name of the hasOne relation.
|
|
80
|
+
* @param definition - The definition of the hasOne relation.
|
|
81
|
+
*/
|
|
82
|
+
hasOne(name, definition) {
|
|
83
|
+
const meta = {
|
|
84
|
+
...definition,
|
|
85
|
+
name,
|
|
86
|
+
type: index_1.RelationType.hasOne,
|
|
87
|
+
targetsMany: false,
|
|
88
|
+
};
|
|
89
|
+
return this.addRelation(meta);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Define a new hasMany relation.
|
|
93
|
+
* @param name - The name of the hasMany relation.
|
|
94
|
+
* @param definition - The definition of the hasMany relation.
|
|
95
|
+
*/
|
|
96
|
+
hasMany(name, definition) {
|
|
97
|
+
const meta = {
|
|
98
|
+
...definition,
|
|
99
|
+
name,
|
|
100
|
+
type: index_1.RelationType.hasMany,
|
|
101
|
+
targetsMany: true,
|
|
102
|
+
};
|
|
103
|
+
return this.addRelation(meta);
|
|
104
|
+
}
|
|
62
105
|
/**
|
|
63
106
|
* Get an array of names of ID properties, which are specified in
|
|
64
107
|
* the model settings or properties with `id` attribute.
|
|
@@ -132,7 +175,8 @@ class Model {
|
|
|
132
175
|
Object.assign(this, data);
|
|
133
176
|
}
|
|
134
177
|
static get modelName() {
|
|
135
|
-
|
|
178
|
+
var _a;
|
|
179
|
+
return ((_a = this.definition) === null || _a === void 0 ? void 0 : _a.name) || this.name;
|
|
136
180
|
}
|
|
137
181
|
/**
|
|
138
182
|
* Serialize into a plain JSON object
|
|
@@ -175,7 +219,7 @@ class Model {
|
|
|
175
219
|
toObject(options) {
|
|
176
220
|
const def = this.constructor.definition;
|
|
177
221
|
const obj = {};
|
|
178
|
-
if (options
|
|
222
|
+
if ((options === null || options === void 0 ? void 0 : options.ignoreUnknownProperties) === false) {
|
|
179
223
|
const hiddenProperties = (def === null || def === void 0 ? void 0 : def.settings.hiddenProperties) || [];
|
|
180
224
|
for (const p in this) {
|
|
181
225
|
if (!hiddenProperties.includes(p)) {
|
package/dist/model.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCA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AC,YAAY,EAAE,CAAC;QAC/C,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;YACxB,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;SACxB;aAAM;YACL,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;gBAC5B,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC;aAC5B;SACF;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAxED,wBAwEC;AAED;;GAEG;AACH,MAAa,KAAK;CAGjB;AAHD,sBAGC;AAMD;;;;;;;GAOG;AACH,SAAgB,kCAAkC,CAChD,UAAa,EACb,IAAgC;IAEhC,MAAM,GAAG,GAAG,UAAU,CAAC,UAAU,CAAC;IAClC,MAAM,KAAK,GAAG,GAAG,CAAC,UAAU,CAAC;IAE7B,KAAK,MAAM,CAAC,IAAI,GAAG,CAAC,SAAS,EAAE;QAC7B,MAAM,OAAO,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACtC,IAAI,CAAC,CAAC,OAAO,IAAI,IAAI,CAAC;YAAE,SAAS;QAEjC,IAAI,GAAG,GACL,wDAAwD;YACxD,WAAW,UAAU,CAAC,SAAS,eAAe,OAAO,MAAM;YAC3D,mBAAmB,CAAC;QAEtB,IAAI,OAAO,IAAI,KAAK,EAAE;YACpB,GAAG;gBACD,iEAAiE;oBACjE,+DAA+D,CAAC;SACnE;QAED,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;KACtB;AACH,CAAC;AAxBD,gFAwBC"}
|
package/dist/query.d.ts
CHANGED
|
@@ -272,6 +272,36 @@ export declare class WhereBuilder<MT extends object = AnyObject> {
|
|
|
272
272
|
* @param where - Where filter
|
|
273
273
|
*/
|
|
274
274
|
impose(where: Where<MT>): this;
|
|
275
|
+
/**
|
|
276
|
+
* Add a `like` condition
|
|
277
|
+
* @param key - Property name
|
|
278
|
+
* @param val - Regexp condition
|
|
279
|
+
*/
|
|
280
|
+
like<K extends KeyOf<MT>>(key: K, val: MT[K]): this;
|
|
281
|
+
/**
|
|
282
|
+
* Add a `nlike` condition
|
|
283
|
+
* @param key - Property name
|
|
284
|
+
* @param val - Regexp condition
|
|
285
|
+
*/
|
|
286
|
+
nlike<K extends KeyOf<MT>>(key: K, val: MT[K]): this;
|
|
287
|
+
/**
|
|
288
|
+
* Add a `ilike` condition
|
|
289
|
+
* @param key - Property name
|
|
290
|
+
* @param val - Regexp condition
|
|
291
|
+
*/
|
|
292
|
+
ilike<K extends KeyOf<MT>>(key: K, val: MT[K]): this;
|
|
293
|
+
/**
|
|
294
|
+
* Add a `nilike` condition
|
|
295
|
+
* @param key - Property name
|
|
296
|
+
* @param val - Regexp condition
|
|
297
|
+
*/
|
|
298
|
+
nilike<K extends KeyOf<MT>>(key: K, val: MT[K]): this;
|
|
299
|
+
/**
|
|
300
|
+
* Add a `regexp` condition
|
|
301
|
+
* @param key - Property name
|
|
302
|
+
* @param val - Regexp condition
|
|
303
|
+
*/
|
|
304
|
+
regexp<K extends KeyOf<MT>>(key: K, val: string | RegExp): this;
|
|
275
305
|
/**
|
|
276
306
|
* Get the where object
|
|
277
307
|
*/
|