@tsed/mongoose 8.0.0-alpha.5 → 8.0.0-alpha.7
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/lib/esm/MongooseModule.js.map +1 -1
- package/lib/esm/decorators/dynamicRef.js +1 -1
- package/lib/esm/decorators/dynamicRef.js.map +1 -1
- package/lib/esm/decorators/indexed.js.map +1 -1
- package/lib/esm/decorators/model.js.map +1 -1
- package/lib/esm/decorators/mongoosePlugin.js.map +1 -1
- package/lib/esm/decorators/numberDecimal.js +1 -1
- package/lib/esm/decorators/numberDecimal.js.map +1 -1
- package/lib/esm/decorators/objectID.js.map +1 -1
- package/lib/esm/decorators/postHook.js.map +1 -1
- package/lib/esm/decorators/preHook.js.map +1 -1
- package/lib/esm/decorators/ref.js.map +1 -1
- package/lib/esm/decorators/schema.js.map +1 -1
- package/lib/esm/decorators/versionKey.js.map +1 -1
- package/lib/esm/decorators/virtualRef.js.map +1 -1
- package/lib/esm/services/MongooseConnections.js +1 -1
- package/lib/esm/services/MongooseConnections.js.map +1 -1
- package/lib/esm/services/MongooseService.js.map +1 -1
- package/lib/esm/utils/createModel.js.map +1 -1
- package/lib/esm/utils/createSchema.js.map +1 -1
- package/lib/esm/utils/resolveRefType.js.map +1 -1
- package/lib/esm/utils/schemaOptions.js.map +1 -1
- package/lib/types/decorators/indexed.d.ts +24 -0
- package/lib/types/decorators/mongoosePlugin.d.ts +24 -0
- package/lib/types/decorators/numberDecimal.d.ts +24 -0
- package/lib/types/decorators/objectID.d.ts +24 -0
- package/lib/types/decorators/schema.d.ts +24 -0
- package/lib/types/interfaces/MongooseConnectionOptions.d.ts +24 -0
- package/lib/types/interfaces/MongooseDocument.d.ts +24 -0
- package/lib/types/interfaces/MongooseModel.d.ts +24 -0
- package/lib/types/interfaces/MongooseSchemaOptions.d.ts +24 -0
- package/lib/types/services/MongooseService.d.ts +24 -0
- package/lib/types/utils/createModel.d.ts +24 -0
- package/lib/types/utils/createSchema.d.ts +24 -0
- package/lib/types/utils/schemaOptions.d.ts +24 -0
- package/package.json +19 -20
- package/vitest.config.mts +4 -4
- package/lib/cjs/MongooseModule.js +0 -36
- package/lib/cjs/MongooseModule.js.map +0 -1
- package/lib/cjs/constants/constants.js +0 -24
- package/lib/cjs/constants/constants.js.map +0 -1
- package/lib/cjs/decorators/auto.js +0 -28
- package/lib/cjs/decorators/auto.js.map +0 -1
- package/lib/cjs/decorators/discriminatorKey.js +0 -6
- package/lib/cjs/decorators/discriminatorKey.js.map +0 -1
- package/lib/cjs/decorators/dynamicRef.js +0 -65
- package/lib/cjs/decorators/dynamicRef.js.map +0 -1
- package/lib/cjs/decorators/excludeIndexes.js +0 -28
- package/lib/cjs/decorators/excludeIndexes.js.map +0 -1
- package/lib/cjs/decorators/expires.js +0 -28
- package/lib/cjs/decorators/expires.js.map +0 -1
- package/lib/cjs/decorators/immutable.js +0 -30
- package/lib/cjs/decorators/immutable.js.map +0 -1
- package/lib/cjs/decorators/indexed.js +0 -26
- package/lib/cjs/decorators/indexed.js.map +0 -1
- package/lib/cjs/decorators/lowercase.js +0 -28
- package/lib/cjs/decorators/lowercase.js.map +0 -1
- package/lib/cjs/decorators/model.js +0 -69
- package/lib/cjs/decorators/model.js.map +0 -1
- package/lib/cjs/decorators/mongooseIndex.js +0 -39
- package/lib/cjs/decorators/mongooseIndex.js.map +0 -1
- package/lib/cjs/decorators/mongooseIndexes.js +0 -39
- package/lib/cjs/decorators/mongooseIndexes.js.map +0 -1
- package/lib/cjs/decorators/mongoosePlugin.js +0 -22
- package/lib/cjs/decorators/mongoosePlugin.js.map +0 -1
- package/lib/cjs/decorators/numberDecimal.js +0 -78
- package/lib/cjs/decorators/numberDecimal.js.map +0 -1
- package/lib/cjs/decorators/objectID.js +0 -32
- package/lib/cjs/decorators/objectID.js.map +0 -1
- package/lib/cjs/decorators/postHook.js +0 -26
- package/lib/cjs/decorators/postHook.js.map +0 -1
- package/lib/cjs/decorators/preHook.js +0 -71
- package/lib/cjs/decorators/preHook.js.map +0 -1
- package/lib/cjs/decorators/ref.js +0 -84
- package/lib/cjs/decorators/ref.js.map +0 -1
- package/lib/cjs/decorators/schema.js +0 -32
- package/lib/cjs/decorators/schema.js.map +0 -1
- package/lib/cjs/decorators/schemaIgnore.js +0 -27
- package/lib/cjs/decorators/schemaIgnore.js.map +0 -1
- package/lib/cjs/decorators/select.js +0 -28
- package/lib/cjs/decorators/select.js.map +0 -1
- package/lib/cjs/decorators/sparse.js +0 -30
- package/lib/cjs/decorators/sparse.js.map +0 -1
- package/lib/cjs/decorators/text.js +0 -29
- package/lib/cjs/decorators/text.js.map +0 -1
- package/lib/cjs/decorators/trim.js +0 -27
- package/lib/cjs/decorators/trim.js.map +0 -1
- package/lib/cjs/decorators/unique.js +0 -27
- package/lib/cjs/decorators/unique.js.map +0 -1
- package/lib/cjs/decorators/uppercase.js +0 -28
- package/lib/cjs/decorators/uppercase.js.map +0 -1
- package/lib/cjs/decorators/versionKey.js +0 -12
- package/lib/cjs/decorators/versionKey.js.map +0 -1
- package/lib/cjs/decorators/virtualRef.js +0 -38
- package/lib/cjs/decorators/virtualRef.js.map +0 -1
- package/lib/cjs/index.js +0 -51
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/interfaces/MongooseConnectionOptions.js +0 -3
- package/lib/cjs/interfaces/MongooseConnectionOptions.js.map +0 -1
- package/lib/cjs/interfaces/MongooseDocument.js +0 -3
- package/lib/cjs/interfaces/MongooseDocument.js.map +0 -1
- package/lib/cjs/interfaces/MongooseModel.js +0 -3
- package/lib/cjs/interfaces/MongooseModel.js.map +0 -1
- package/lib/cjs/interfaces/MongooseModelOptions.js +0 -3
- package/lib/cjs/interfaces/MongooseModelOptions.js.map +0 -1
- package/lib/cjs/interfaces/MongooseSchemaOptions.js +0 -3
- package/lib/cjs/interfaces/MongooseSchemaOptions.js.map +0 -1
- package/lib/cjs/interfaces/MongooseSchemaTypes.js +0 -10
- package/lib/cjs/interfaces/MongooseSchemaTypes.js.map +0 -1
- package/lib/cjs/interfaces/MongooseVirtualRefOptions.js +0 -3
- package/lib/cjs/interfaces/MongooseVirtualRefOptions.js.map +0 -1
- package/lib/cjs/interfaces/interfaces.js +0 -3
- package/lib/cjs/interfaces/interfaces.js.map +0 -1
- package/lib/cjs/package.json +0 -3
- package/lib/cjs/registries/MongooseModels.js +0 -5
- package/lib/cjs/registries/MongooseModels.js.map +0 -1
- package/lib/cjs/services/MongooseConnections.js +0 -47
- package/lib/cjs/services/MongooseConnections.js.map +0 -1
- package/lib/cjs/services/MongooseService.js +0 -78
- package/lib/cjs/services/MongooseService.js.map +0 -1
- package/lib/cjs/utils/createModel.js +0 -44
- package/lib/cjs/utils/createModel.js.map +0 -1
- package/lib/cjs/utils/createSchema.js +0 -161
- package/lib/cjs/utils/createSchema.js.map +0 -1
- package/lib/cjs/utils/resolveRefType.js +0 -19
- package/lib/cjs/utils/resolveRefType.js.map +0 -1
- package/lib/cjs/utils/schemaOptions.js +0 -60
- package/lib/cjs/utils/schemaOptions.js.map +0 -1
- package/lib/esm/package.json +0 -3
- package/lib/types-esm/MongooseModule.d.ts +0 -13
- package/lib/types-esm/constants/constants.d.ts +0 -20
- package/lib/types-esm/decorators/auto.d.ts +0 -20
- package/lib/types-esm/decorators/discriminatorKey.d.ts +0 -1
- package/lib/types-esm/decorators/dynamicRef.d.ts +0 -35
- package/lib/types-esm/decorators/excludeIndexes.d.ts +0 -20
- package/lib/types-esm/decorators/expires.d.ts +0 -20
- package/lib/types-esm/decorators/immutable.d.ts +0 -22
- package/lib/types-esm/decorators/indexed.d.ts +0 -19
- package/lib/types-esm/decorators/lowercase.d.ts +0 -20
- package/lib/types-esm/decorators/model.d.ts +0 -39
- package/lib/types-esm/decorators/mongooseIndex.d.ts +0 -27
- package/lib/types-esm/decorators/mongooseIndexes.d.ts +0 -32
- package/lib/types-esm/decorators/mongoosePlugin.d.ts +0 -11
- package/lib/types-esm/decorators/numberDecimal.d.ts +0 -32
- package/lib/types-esm/decorators/objectID.d.ts +0 -19
- package/lib/types-esm/decorators/postHook.d.ts +0 -48
- package/lib/types-esm/decorators/preHook.d.ts +0 -49
- package/lib/types-esm/decorators/ref.d.ts +0 -38
- package/lib/types-esm/decorators/schema.d.ts +0 -54
- package/lib/types-esm/decorators/schemaIgnore.d.ts +0 -19
- package/lib/types-esm/decorators/select.d.ts +0 -20
- package/lib/types-esm/decorators/sparse.d.ts +0 -22
- package/lib/types-esm/decorators/text.d.ts +0 -21
- package/lib/types-esm/decorators/trim.d.ts +0 -19
- package/lib/types-esm/decorators/unique.d.ts +0 -19
- package/lib/types-esm/decorators/uppercase.d.ts +0 -20
- package/lib/types-esm/decorators/versionKey.d.ts +0 -1
- package/lib/types-esm/decorators/virtualRef.d.ts +0 -26
- package/lib/types-esm/index.d.ts +0 -47
- package/lib/types-esm/interfaces/MongooseConnectionOptions.d.ts +0 -9
- package/lib/types-esm/interfaces/MongooseDocument.d.ts +0 -2
- package/lib/types-esm/interfaces/MongooseModel.d.ts +0 -8
- package/lib/types-esm/interfaces/MongooseModelOptions.d.ts +0 -7
- package/lib/types-esm/interfaces/MongooseSchemaOptions.d.ts +0 -36
- package/lib/types-esm/interfaces/MongooseSchemaTypes.d.ts +0 -5
- package/lib/types-esm/interfaces/MongooseVirtualRefOptions.d.ts +0 -9
- package/lib/types-esm/interfaces/interfaces.d.ts +0 -8
- package/lib/types-esm/registries/MongooseModels.d.ts +0 -2
- package/lib/types-esm/services/MongooseConnections.d.ts +0 -9
- package/lib/types-esm/services/MongooseService.d.ts +0 -25
- package/lib/types-esm/utils/createModel.d.ts +0 -18
- package/lib/types-esm/utils/createSchema.d.ts +0 -28
- package/lib/types-esm/utils/resolveRefType.d.ts +0 -5
- package/lib/types-esm/utils/schemaOptions.d.ts +0 -14
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NumberDecimal = exports.DecimalFormat = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const ajv_1 = require("@tsed/ajv");
|
|
6
|
-
const core_1 = require("@tsed/core");
|
|
7
|
-
const json_mapper_1 = require("@tsed/json-mapper");
|
|
8
|
-
const schema_1 = require("@tsed/schema");
|
|
9
|
-
const mongoose_1 = require("mongoose");
|
|
10
|
-
const constants_js_1 = require("../constants/constants.js");
|
|
11
|
-
let DecimalFormat = class DecimalFormat {
|
|
12
|
-
validate(num) {
|
|
13
|
-
return (0, core_1.isString)(num) || (0, core_1.isNumber)(num);
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
DecimalFormat = tslib_1.__decorate([
|
|
17
|
-
(0, ajv_1.Formats)("decimal", { type: "number" })
|
|
18
|
-
], DecimalFormat);
|
|
19
|
-
exports.DecimalFormat = DecimalFormat;
|
|
20
|
-
function isDecimal(value) {
|
|
21
|
-
return value && value._bsontype === "Decimal128";
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Tell Mongoose whether to define an Decimal128 property.
|
|
25
|
-
* Will be serialized as `number` with format as `decimal`.
|
|
26
|
-
* ### Example
|
|
27
|
-
*
|
|
28
|
-
* ```typescript
|
|
29
|
-
* @Model()
|
|
30
|
-
* export class PriceModel {
|
|
31
|
-
* @NumberDecimal()
|
|
32
|
-
* price: Decimal128;
|
|
33
|
-
* }
|
|
34
|
-
* ```
|
|
35
|
-
* Optionally using custom decimal type, such as `Big` from big.js
|
|
36
|
-
* ```typescript
|
|
37
|
-
* @Model()
|
|
38
|
-
* export class PriceModel {
|
|
39
|
-
* @NumberDecimal(Big)
|
|
40
|
-
* price: Big;
|
|
41
|
-
* }
|
|
42
|
-
* ```
|
|
43
|
-
* @param type Optional decimal type constructor
|
|
44
|
-
* @decorator
|
|
45
|
-
* @mongoose
|
|
46
|
-
* @schema
|
|
47
|
-
*/
|
|
48
|
-
function NumberDecimal(type) {
|
|
49
|
-
const schema = {
|
|
50
|
-
type: mongoose_1.Schema.Types.Decimal128
|
|
51
|
-
};
|
|
52
|
-
if (type) {
|
|
53
|
-
// Define property getter to convert Decimal128 to custom type
|
|
54
|
-
schema.get = (value) => {
|
|
55
|
-
return isDecimal(value) ? new type(value) : value;
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
return (0, core_1.useDecorators)((0, schema_1.Property)(Number), (0, schema_1.Format)("decimal"), (0, schema_1.Example)(12.34), (0, core_1.StoreMerge)(constants_js_1.MONGOOSE_SCHEMA, schema),
|
|
59
|
-
// Deserialize number value from JSON to Decimal128
|
|
60
|
-
(0, json_mapper_1.OnDeserialize)((value) => {
|
|
61
|
-
if (value === undefined) {
|
|
62
|
-
return undefined;
|
|
63
|
-
}
|
|
64
|
-
if (type) {
|
|
65
|
-
return new type(value);
|
|
66
|
-
}
|
|
67
|
-
if ((0, core_1.isString)(value)) {
|
|
68
|
-
return mongoose_1.Types.Decimal128.fromString(value);
|
|
69
|
-
}
|
|
70
|
-
return mongoose_1.Types.Decimal128.fromString(`${value}`);
|
|
71
|
-
}),
|
|
72
|
-
// Serialize decimal value to floating point number
|
|
73
|
-
(0, json_mapper_1.OnSerialize)((value, ctx) => {
|
|
74
|
-
return value && Number(value);
|
|
75
|
-
}));
|
|
76
|
-
}
|
|
77
|
-
exports.NumberDecimal = NumberDecimal;
|
|
78
|
-
//# sourceMappingURL=numberDecimal.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"numberDecimal.js","sourceRoot":"","sources":["../../../src/decorators/numberDecimal.ts"],"names":[],"mappings":";;;;AAAA,mCAAkD;AAClD,qCAAyE;AACzE,mDAA6D;AAC7D,yCAAuD;AACvD,uCAA4E;AAC5E,4DAA0D;AAGnD,IAAM,aAAa,GAAnB,MAAM,aAAa;IACxB,QAAQ,CAAC,GAAoB;QAC3B,OAAO,IAAA,eAAQ,EAAC,GAAG,CAAC,IAAI,IAAA,eAAQ,EAAC,GAAG,CAAC,CAAC;IACxC,CAAC;CACF,CAAA;AAJY,aA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,IAAA,yBAAW,EAAC,CAAC,KAAU,EAAE,GAAG,EAAE,EAAE;QAC9B,OAAO,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC,CAAC,CACH,CAAC;AACJ,CAAC;AArCD,sCAqCC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ObjectID = void 0;
|
|
4
|
-
const core_1 = require("@tsed/core");
|
|
5
|
-
const schema_1 = require("@tsed/schema");
|
|
6
|
-
const mongoose_1 = require("mongoose");
|
|
7
|
-
const auto_js_1 = require("./auto.js");
|
|
8
|
-
const schema_js_1 = require("./schema.js");
|
|
9
|
-
/**
|
|
10
|
-
* Tell Mongoose whether to define an ObjectId property.
|
|
11
|
-
* ### Example
|
|
12
|
-
*
|
|
13
|
-
* ```typescript
|
|
14
|
-
* @Model()
|
|
15
|
-
* export class EventModel {
|
|
16
|
-
* @ObjectId('id')
|
|
17
|
-
* _id: string;
|
|
18
|
-
* }
|
|
19
|
-
* ```
|
|
20
|
-
* @param name
|
|
21
|
-
* @decorator
|
|
22
|
-
* @mongoose
|
|
23
|
-
* @schema
|
|
24
|
-
*/
|
|
25
|
-
function ObjectID(name) {
|
|
26
|
-
return (0, core_1.useDecorators)(name && (0, schema_1.Name)(name), (0, schema_1.Pattern)(/^[0-9a-fA-F]{24}$/), (0, schema_1.Description)("An ObjectID"), (0, schema_1.Example)("5ce7ad3028890bd71749d477"), (0, auto_js_1.Auto)(), (0, schema_js_1.Schema)({
|
|
27
|
-
type: mongoose_1.Types.ObjectId,
|
|
28
|
-
match: undefined
|
|
29
|
-
}));
|
|
30
|
-
}
|
|
31
|
-
exports.ObjectID = ObjectID;
|
|
32
|
-
//# sourceMappingURL=objectID.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"objectID.js","sourceRoot":"","sources":["../../../src/decorators/objectID.ts"],"names":[],"mappings":";;;AAAA,qCAAyC;AAEzC,yCAAiE;AACjE,uCAA+B;AAC/B,uCAA+B;AAC/B,2CAAmC;AAEnC;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,QAAQ,CAAC,IAAa;IACpC,OAAO,IAAA,oBAAa,EAClB,IAAI,IAAI,IAAA,aAAI,EAAC,IAAI,CAAC,EAClB,IAAA,gBAAO,EAAC,mBAAmB,CAAC,EAC5B,IAAA,oBAAW,EAAC,aAAa,CAAC,EAC1B,IAAA,gBAAO,EAAC,0BAA0B,CAAC,EACnC,IAAA,cAAI,GAAE,EACN,IAAA,kBAAM,EAAC;QACL,IAAI,EAAE,gBAAK,CAAC,QAAQ;QACpB,KAAK,EAAE,SAAS;KACjB,CAAC,CACH,CAAC;AACJ,CAAC;AAZD,4BAYC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PostHook = void 0;
|
|
4
|
-
const core_1 = require("@tsed/core");
|
|
5
|
-
const schemaOptions_js_1 = require("../utils/schemaOptions.js");
|
|
6
|
-
function PostHook(method, ...params) {
|
|
7
|
-
return ((...args) => {
|
|
8
|
-
let options = params[1];
|
|
9
|
-
let fn = params[0];
|
|
10
|
-
if ((0, core_1.decoratorTypeOf)(args) === core_1.DecoratorTypes.METHOD_STC) {
|
|
11
|
-
options = params[0];
|
|
12
|
-
fn = args[0][args[1]].bind(args[0]);
|
|
13
|
-
}
|
|
14
|
-
(0, schemaOptions_js_1.schemaOptions)(args[0], {
|
|
15
|
-
post: [
|
|
16
|
-
{
|
|
17
|
-
method,
|
|
18
|
-
fn,
|
|
19
|
-
options
|
|
20
|
-
}
|
|
21
|
-
]
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
exports.PostHook = PostHook;
|
|
26
|
-
//# sourceMappingURL=postHook.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"postHook.js","sourceRoot":"","sources":["../../../src/decorators/postHook.ts"],"names":[],"mappings":";;;AAAA,qCAAkF;AAElF,gEAAwD;AAgDxD,SAAgB,QAAQ,CAAU,MAAc,EAAE,GAAG,MAAa;IAChE,OAAO,CAAC,CAAC,GAAG,IAAW,EAAE,EAAE;QACzB,IAAI,OAAO,GAAwB,MAAM,CAAC,CAAC,CAAC,CAAC;QAC7C,IAAI,EAAE,GAA0B,MAAM,CAAC,CAAC,CAAC,CAAC;QAE1C,IAAI,IAAA,sBAAe,EAAC,IAAI,CAAC,KAAK,qBAAc,CAAC,UAAU,EAAE;YACvD,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;YACpB,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;SACrC;QAED,IAAA,gCAAa,EAAC,IAAI,CAAC,CAAC,CAAC,EAAE;YACrB,IAAI,EAAE;gBACJ;oBACE,MAAM;oBACN,EAAE;oBACF,OAAO;iBACR;aACF;SACF,CAAC,CAAC;IACL,CAAC,CAAQ,CAAC;AACZ,CAAC;AApBD,4BAoBC"}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PreHook = void 0;
|
|
4
|
-
const core_1 = require("@tsed/core");
|
|
5
|
-
const schemaOptions_js_1 = require("../utils/schemaOptions.js");
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
* We can simply attach a `@PreHook` decorator to your model class and
|
|
9
|
-
* define the hook function like you normally would in Mongoose.
|
|
10
|
-
*
|
|
11
|
-
* ```typescript
|
|
12
|
-
* import {Ignore, Required} from "@tsed/common";
|
|
13
|
-
* import {PreHook, Model} from "@tsed/mongoose";
|
|
14
|
-
*
|
|
15
|
-
* @Model()
|
|
16
|
-
* @PreHook("save", (car: CarModel, next) => {
|
|
17
|
-
* if (car.model === 'Tesla') {
|
|
18
|
-
* car.isFast = true;
|
|
19
|
-
* }
|
|
20
|
-
* next();
|
|
21
|
-
*})
|
|
22
|
-
* export class CarModel {
|
|
23
|
-
*
|
|
24
|
-
* @Ignore()
|
|
25
|
-
* _id: string;
|
|
26
|
-
*
|
|
27
|
-
* @Required()
|
|
28
|
-
* model: string;
|
|
29
|
-
*
|
|
30
|
-
* @Required()
|
|
31
|
-
* isFast: boolean;
|
|
32
|
-
*
|
|
33
|
-
* // or Prehook on static method
|
|
34
|
-
* @PreHook("save")
|
|
35
|
-
* static preSave(car: CarModel, next) {
|
|
36
|
-
* if (car.model === 'Tesla') {
|
|
37
|
-
* car.isFast = true;
|
|
38
|
-
* }
|
|
39
|
-
* next();
|
|
40
|
-
* }
|
|
41
|
-
* }
|
|
42
|
-
* ```
|
|
43
|
-
*
|
|
44
|
-
* This will execute the pre-save hook each time a `CarModel` document is saved.
|
|
45
|
-
*
|
|
46
|
-
* @param {string} method
|
|
47
|
-
* @param fn
|
|
48
|
-
* @param options
|
|
49
|
-
* @returns {Function}
|
|
50
|
-
* @decorator
|
|
51
|
-
* @class
|
|
52
|
-
*/
|
|
53
|
-
function PreHook(method, fn, options) {
|
|
54
|
-
return (...args) => {
|
|
55
|
-
if ((0, core_1.decoratorTypeOf)(args) === core_1.DecoratorTypes.METHOD_STC) {
|
|
56
|
-
options = fn;
|
|
57
|
-
fn = args[0][args[1]].bind(args[0]);
|
|
58
|
-
}
|
|
59
|
-
(0, schemaOptions_js_1.schemaOptions)(args[0], {
|
|
60
|
-
pre: [
|
|
61
|
-
{
|
|
62
|
-
method,
|
|
63
|
-
fn: fn,
|
|
64
|
-
options
|
|
65
|
-
}
|
|
66
|
-
]
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
exports.PreHook = PreHook;
|
|
71
|
-
//# sourceMappingURL=preHook.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"preHook.js","sourceRoot":"","sources":["../../../src/decorators/preHook.ts"],"names":[],"mappings":";;;AAAA,qCAA2D;AAE3D,gEAAwD;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,SAAgB,OAAO,CAAU,MAAc,EAAE,EAA+C,EAAE,OAA6B;IAC7H,OAAO,CAAC,GAAG,IAAW,EAAE,EAAE;QACxB,IAAI,IAAA,sBAAe,EAAC,IAAI,CAAC,KAAK,qBAAc,CAAC,UAAU,EAAE;YACvD,OAAO,GAAG,EAAyB,CAAC;YACpC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;SACrC;QAED,IAAA,gCAAa,EAAC,IAAI,CAAC,CAAC,CAAC,EAAE;YACrB,GAAG,EAAE;gBACH;oBACE,MAAM;oBACN,EAAE,EAAE,EAA0B;oBAC9B,OAAO;iBACR;aACF;SACF,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAjBD,0BAiBC"}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Ref = void 0;
|
|
4
|
-
const core_1 = require("@tsed/core");
|
|
5
|
-
const json_mapper_1 = require("@tsed/json-mapper");
|
|
6
|
-
const schema_1 = require("@tsed/schema");
|
|
7
|
-
const mongoose_1 = require("mongoose");
|
|
8
|
-
const constants_js_1 = require("../constants/constants.js");
|
|
9
|
-
const MongooseSchemaTypes_js_1 = require("../interfaces/MongooseSchemaTypes.js");
|
|
10
|
-
const MongooseModels_js_1 = require("../registries/MongooseModels.js");
|
|
11
|
-
function isRef(value) {
|
|
12
|
-
return (0, core_1.isObjectID)(value) || (0, core_1.isString)(value);
|
|
13
|
-
}
|
|
14
|
-
function PopulateGroups(populatedGroups) {
|
|
15
|
-
return (0, core_1.useDecorators)((0, schema_1.ForwardGroups)(true), (0, schema_1.JsonEntityFn)((store) => {
|
|
16
|
-
store.schema.$hooks.on("oneOf", (obj, givenGroups) => {
|
|
17
|
-
if ((0, schema_1.matchGroups)(populatedGroups, givenGroups)) {
|
|
18
|
-
return obj.filter((x) => x.type === "string"); // keep the object id;
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
return obj.filter((x) => x.type !== "string"); // keep the ref definition
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
}));
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Define a property as mongoose reference to other Model (decorated with @Model).
|
|
28
|
-
*
|
|
29
|
-
* ### Example
|
|
30
|
-
*
|
|
31
|
-
* ```typescript
|
|
32
|
-
*
|
|
33
|
-
* @Model()
|
|
34
|
-
* class FooModel {
|
|
35
|
-
*
|
|
36
|
-
* @Ref(Foo2Model)
|
|
37
|
-
* field: Ref<Foo2Model>
|
|
38
|
-
*
|
|
39
|
-
* @Ref(Foo2Model)
|
|
40
|
-
* list: Ref<Foo2Model>[]
|
|
41
|
-
* }
|
|
42
|
-
*
|
|
43
|
-
* @Model()
|
|
44
|
-
* class Foo2Model {
|
|
45
|
-
* }
|
|
46
|
-
* ```
|
|
47
|
-
*
|
|
48
|
-
* @param model
|
|
49
|
-
* @param options
|
|
50
|
-
* @returns {Function}
|
|
51
|
-
* @decorator
|
|
52
|
-
* @mongoose
|
|
53
|
-
* @property
|
|
54
|
-
*/
|
|
55
|
-
function Ref(model, options = MongooseSchemaTypes_js_1.MongooseSchemaTypes.OBJECT_ID) {
|
|
56
|
-
if (!model) {
|
|
57
|
-
throw new Error("A model is required on `@Ref(model)` decorator. Please give a model or wrap it inside an arrow function if you have a circular reference.");
|
|
58
|
-
}
|
|
59
|
-
const getType = () => ((0, core_1.isString)(model) ? MongooseModels_js_1.MongooseModels.get(model) : (0, core_1.isArrowFn)(model) ? model() : model);
|
|
60
|
-
const populatedGroups = ((0, core_1.isObject)(options) && options.populatedGroups) || [];
|
|
61
|
-
return (0, core_1.useDecorators)((0, schema_1.Property)(Object), (0, core_1.StoreMerge)(constants_js_1.MONGOOSE_SCHEMA, {
|
|
62
|
-
type: mongoose_1.Schema.Types[(0, core_1.isObject)(options) ? options.type || MongooseSchemaTypes_js_1.MongooseSchemaTypes.OBJECT_ID : options],
|
|
63
|
-
ref: model
|
|
64
|
-
}), (0, json_mapper_1.OnDeserialize)((value) => {
|
|
65
|
-
if (isRef(value)) {
|
|
66
|
-
return value.toString();
|
|
67
|
-
}
|
|
68
|
-
if ((0, core_1.isCollection)(value) && isRef(value[0])) {
|
|
69
|
-
return value.map(String);
|
|
70
|
-
}
|
|
71
|
-
return (0, json_mapper_1.deserialize)(value, { type: getType(), useAlias: false });
|
|
72
|
-
}), (0, json_mapper_1.OnSerialize)((value, ctx) => {
|
|
73
|
-
if (isRef(value)) {
|
|
74
|
-
return value.toString();
|
|
75
|
-
}
|
|
76
|
-
if ((0, core_1.isCollection)(value) && isRef(value[0])) {
|
|
77
|
-
return value.map(String);
|
|
78
|
-
}
|
|
79
|
-
const type = getType();
|
|
80
|
-
return (0, json_mapper_1.serialize)(value, { ...ctx, type });
|
|
81
|
-
}), (0, schema_1.OneOf)((0, schema_1.string)().example("5ce7ad3028890bd71749d477").description("A reference ObjectID"), (0, schema_1.lazyRef)(getType)), populatedGroups.length && PopulateGroups(populatedGroups));
|
|
82
|
-
}
|
|
83
|
-
exports.Ref = Ref;
|
|
84
|
-
//# sourceMappingURL=ref.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ref.js","sourceRoot":"","sources":["../../../src/decorators/ref.ts"],"names":[],"mappings":";;;AAAA,qCAAoH;AACpH,mDAAqF;AACrF,yCAAwG;AACxG,uCAAkD;AAClD,4DAA0D;AAC1D,iFAAyE;AACzE,uEAA+D;AAO/D,SAAS,KAAK,CAAC,KAA+B;IAC5C,OAAO,IAAA,iB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,CAAC,CAAC,EACF,IAAA,cAAK,EAAC,IAAA,eAAM,GAAE,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC,WAAW,CAAC,sBAAsB,CAAC,EAAE,IAAA,gBAAO,EAAC,OAAO,CAAC,CAAC,EACzG,eAAe,CAAC,MAAM,IAAI,cAAc,CAAC,eAAe,CAAC,CACrC,CAAC;AACzB,CAAC;AA9CD,kBA8CC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MongooseSchema = exports.Schema = void 0;
|
|
4
|
-
const core_1 = require("@tsed/core");
|
|
5
|
-
const di_1 = require("@tsed/di");
|
|
6
|
-
const schema_1 = require("@tsed/schema");
|
|
7
|
-
const constants_js_1 = require("../constants/constants.js");
|
|
8
|
-
const createSchema_js_1 = require("../utils/createSchema.js");
|
|
9
|
-
function Schema(options = {}) {
|
|
10
|
-
return (...parameters) => {
|
|
11
|
-
switch ((0, core_1.decoratorTypeOf)(parameters)) {
|
|
12
|
-
case "property":
|
|
13
|
-
return (0, core_1.useDecorators)((0, schema_1.Property)(), (0, core_1.StoreMerge)(constants_js_1.MONGOOSE_SCHEMA, options))(parameters[0], parameters[1], parameters[2]);
|
|
14
|
-
case "class":
|
|
15
|
-
const { token } = (0, createSchema_js_1.getSchemaToken)(parameters[0], options);
|
|
16
|
-
(0, di_1.registerProvider)({
|
|
17
|
-
provide: token,
|
|
18
|
-
deps: [],
|
|
19
|
-
useFactory() {
|
|
20
|
-
return (0, createSchema_js_1.getSchema)(parameters[0], options);
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
break;
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
exports.Schema = Schema;
|
|
28
|
-
function MongooseSchema(options = {}) {
|
|
29
|
-
return Schema(options);
|
|
30
|
-
}
|
|
31
|
-
exports.MongooseSchema = MongooseSchema;
|
|
32
|
-
//# sourceMappingURL=schema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/decorators/schema.ts"],"names":[],"mappings":";;;AAAA,qCAAsE;AACtE,iCAA0C;AAC1C,yCAAsC;AAEtC,4DAA0D;AAE1D,8DAAmE;AA4BnE,SAAgB,MAAM,CAAC,UAA0D,EAAE;IACjF,OAAO,CAAC,GAAG,UAAiB,EAAE,EAAE;QAC9B,QAAQ,IAAA,sBAAe,EAAC,UAAU,CAAC,EAAE;YACnC,KAAK,UAAU;gBACb,OAAO,IAAA,oBAAa,EAAC,IAAA,iBAAQ,GAAE,EAAE,IAAA,iBAAU,EAAC,8BAAe,EAAE,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;YAEtH,KAAK,OAAO;gBACV,MAAM,EAAC,KAAK,EAAC,GAAG,IAAA,gCAAc,EAAC,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;gBAEvD,IAAA,qBAAgB,EAAC;oBACf,OAAO,EAAE,KAAK;oBACd,IAAI,EAAE,EAAE;oBACR,UAAU;wBACR,OAAO,IAAA,2BAAS,EAAC,UAAU,CAAC,CAAC,CAAC,EAAE,OAAc,CAAC,CAAC;oBAClD,CAAC;iBACF,CAAC,CAAC;gBACH,MAAM;SACT;IACH,CAAC,CAAC;AACJ,CAAC;AAnBD,wBAmBC;AA4BD,SAAgB,cAAc,CAAC,UAA0D,EAAE;IACzF,OAAO,MAAM,CAAC,OAAc,CAAC,CAAC;AAChC,CAAC;AAFD,wCAEC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SchemaIgnore = void 0;
|
|
4
|
-
const schema_js_1 = require("./schema.js");
|
|
5
|
-
/**
|
|
6
|
-
* Do not apply this property to schema (create virtual property)
|
|
7
|
-
*
|
|
8
|
-
* ### Example
|
|
9
|
-
*
|
|
10
|
-
* ```typescript
|
|
11
|
-
* @Model()
|
|
12
|
-
* @SchemaIgnore()
|
|
13
|
-
* @Property()
|
|
14
|
-
* kind: string;
|
|
15
|
-
*
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* @returns {Function}
|
|
19
|
-
* @decorator
|
|
20
|
-
* @mongoose
|
|
21
|
-
* @class
|
|
22
|
-
*/
|
|
23
|
-
function SchemaIgnore() {
|
|
24
|
-
return (0, schema_js_1.MongooseSchema)({ schemaIgnore: true });
|
|
25
|
-
}
|
|
26
|
-
exports.SchemaIgnore = SchemaIgnore;
|
|
27
|
-
//# sourceMappingURL=schemaIgnore.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schemaIgnore.js","sourceRoot":"","sources":["../../../src/decorators/schemaIgnore.ts"],"names":[],"mappings":";;;AAAA,2CAA2C;AAE3C;;;;;;;;;;;;;;;;;GAiBG;AAEH,SAAgB,YAAY;IAC1B,OAAO,IAAA,0BAAc,EAAC,EAAC,YAAY,EAAE,IAAI,EAAQ,CAAC,CAAC;AACrD,CAAC;AAFD,oCAEC"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Select = void 0;
|
|
4
|
-
const schema_js_1 = require("./schema.js");
|
|
5
|
-
/**
|
|
6
|
-
* Tell Mongoose to set default select() behavior for this path.
|
|
7
|
-
*
|
|
8
|
-
* ### Example
|
|
9
|
-
*
|
|
10
|
-
* ```typescript
|
|
11
|
-
* @Model()
|
|
12
|
-
* export class EventModel {
|
|
13
|
-
* @Select()
|
|
14
|
-
* field: string;
|
|
15
|
-
* }
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* @param {boolean | any} select
|
|
19
|
-
* @returns {Function}
|
|
20
|
-
* @decorator
|
|
21
|
-
* @mongoose
|
|
22
|
-
* @property
|
|
23
|
-
*/
|
|
24
|
-
function Select(select = true) {
|
|
25
|
-
return (0, schema_js_1.MongooseSchema)({ select });
|
|
26
|
-
}
|
|
27
|
-
exports.Select = Select;
|
|
28
|
-
//# sourceMappingURL=select.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"select.js","sourceRoot":"","sources":["../../../src/decorators/select.ts"],"names":[],"mappings":";;;AAAA,2CAA2C;AAE3C;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,MAAM,CAAC,SAAwB,IAAI;IACjD,OAAO,IAAA,0BAAc,EAAC,EAAC,MAAM,EAAC,CAAC,CAAC;AAClC,CAAC;AAFD,wBAEC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Sparse = void 0;
|
|
4
|
-
const schema_js_1 = require("./schema.js");
|
|
5
|
-
/**
|
|
6
|
-
* If [truthy](https://masteringjs.io/tutorials/fundamentals/truthy), Mongoose will
|
|
7
|
-
* disallow changes to this path once the document is saved to the database for the first time. Read more
|
|
8
|
-
* about [immutability in Mongoose here](http://thecodebarbarian.com/whats-new-in-mongoose-5-6-immutable-properties.html).
|
|
9
|
-
*
|
|
10
|
-
* ### Example
|
|
11
|
-
*
|
|
12
|
-
* ```typescript
|
|
13
|
-
* @Model()
|
|
14
|
-
* export class EventModel {
|
|
15
|
-
* @Sparse()
|
|
16
|
-
* field: string;
|
|
17
|
-
* }
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* @param {boolean | number} sparse
|
|
21
|
-
* @returns {Function}
|
|
22
|
-
* @decorator
|
|
23
|
-
* @mongoose
|
|
24
|
-
* @property
|
|
25
|
-
*/
|
|
26
|
-
function Sparse(sparse = true) {
|
|
27
|
-
return (0, schema_js_1.MongooseSchema)({ sparse });
|
|
28
|
-
}
|
|
29
|
-
exports.Sparse = Sparse;
|
|
30
|
-
//# sourceMappingURL=sparse.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sparse.js","sourceRoot":"","sources":["../../../src/decorators/sparse.ts"],"names":[],"mappings":";;;AAAA,2CAA2C;AAE3C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,MAAM,CAAC,SAA2B,IAAI;IACpD,OAAO,IAAA,0BAAc,EAAC,EAAC,MAAM,EAAQ,CAAC,CAAC;AACzC,CAAC;AAFD,wBAEC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Text = void 0;
|
|
4
|
-
const schema_js_1 = require("./schema.js");
|
|
5
|
-
/**
|
|
6
|
-
* If [truthy](https://masteringjs.io/tutorials/fundamentals/truthy), Mongoose
|
|
7
|
-
* will build a text index on this path.
|
|
8
|
-
*
|
|
9
|
-
* ### Example
|
|
10
|
-
*
|
|
11
|
-
* ```typescript
|
|
12
|
-
* @Model()
|
|
13
|
-
* export class EventModel {
|
|
14
|
-
* @Text()
|
|
15
|
-
* field: string;
|
|
16
|
-
* }
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* @param {boolean | number | any} text
|
|
20
|
-
* @returns {Function}
|
|
21
|
-
* @decorator
|
|
22
|
-
* @mongoose
|
|
23
|
-
* @property
|
|
24
|
-
*/
|
|
25
|
-
function Text(text = true) {
|
|
26
|
-
return (0, schema_js_1.MongooseSchema)({ text });
|
|
27
|
-
}
|
|
28
|
-
exports.Text = Text;
|
|
29
|
-
//# sourceMappingURL=text.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../../src/decorators/text.ts"],"names":[],"mappings":";;;AAAA,2CAA2C;AAE3C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,IAAI,CAAC,OAA+B,IAAI;IACtD,OAAO,IAAA,0BAAc,EAAC,EAAC,IAAI,EAAQ,CAAC,CAAC;AACvC,CAAC;AAFD,oBAEC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Trim = void 0;
|
|
4
|
-
const schema_js_1 = require("./schema.js");
|
|
5
|
-
/**
|
|
6
|
-
* Tell Mongoose to make the property trimmable.
|
|
7
|
-
*
|
|
8
|
-
* ### Example
|
|
9
|
-
*
|
|
10
|
-
* ```typescript
|
|
11
|
-
* @Model()
|
|
12
|
-
* export class EventModel {
|
|
13
|
-
* @Trim()
|
|
14
|
-
* name: string;
|
|
15
|
-
* }
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* @returns {Function}
|
|
19
|
-
* @decorator
|
|
20
|
-
* @mongoose
|
|
21
|
-
* @property
|
|
22
|
-
*/
|
|
23
|
-
function Trim() {
|
|
24
|
-
return (0, schema_js_1.MongooseSchema)({ trim: true });
|
|
25
|
-
}
|
|
26
|
-
exports.Trim = Trim;
|
|
27
|
-
//# sourceMappingURL=trim.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"trim.js","sourceRoot":"","sources":["../../../src/decorators/trim.ts"],"names":[],"mappings":";;;AAAA,2CAA2C;AAE3C;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,IAAI;IAClB,OAAO,IAAA,0BAAc,EAAC,EAAC,IAAI,EAAE,IAAI,EAAC,CAAC,CAAC;AACtC,CAAC;AAFD,oBAEC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Unique = void 0;
|
|
4
|
-
const schema_js_1 = require("./schema.js");
|
|
5
|
-
/**
|
|
6
|
-
* Tell Mongoose to ensure a unique index is created for this path.
|
|
7
|
-
*
|
|
8
|
-
* ### Example
|
|
9
|
-
*
|
|
10
|
-
* ```typescript
|
|
11
|
-
* @Model()
|
|
12
|
-
* export class EventModel {
|
|
13
|
-
* @Unique()
|
|
14
|
-
* index: string;
|
|
15
|
-
* }
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* @param {boolean | any} unique
|
|
19
|
-
* @returns {Function}
|
|
20
|
-
* @decorator
|
|
21
|
-
* @mongoose
|
|
22
|
-
*/
|
|
23
|
-
function Unique(unique = true) {
|
|
24
|
-
return (0, schema_js_1.MongooseSchema)({ unique });
|
|
25
|
-
}
|
|
26
|
-
exports.Unique = Unique;
|
|
27
|
-
//# sourceMappingURL=unique.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unique.js","sourceRoot":"","sources":["../../../src/decorators/unique.ts"],"names":[],"mappings":";;;AAAA,2CAA2C;AAE3C;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,MAAM,CAAC,SAAwB,IAAI;IACjD,OAAO,IAAA,0BAAc,EAAC,EAAC,MAAM,EAAC,CAAC,CAAC;AAClC,CAAC;AAFD,wBAEC"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Uppercase = void 0;
|
|
4
|
-
const schema_js_1 = require("./schema.js");
|
|
5
|
-
/**
|
|
6
|
-
* If truthy, Mongoose will add a custom setter that uppercases this string using JavaScript's built-in String#toUpperCase().
|
|
7
|
-
*
|
|
8
|
-
* ### Example
|
|
9
|
-
*
|
|
10
|
-
* ```typescript
|
|
11
|
-
* @Model()
|
|
12
|
-
* export class EventModel {
|
|
13
|
-
* @Uppercase()
|
|
14
|
-
* field: string;
|
|
15
|
-
* }
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* @param {boolean} uppercase
|
|
19
|
-
* @returns {Function}
|
|
20
|
-
* @decorator
|
|
21
|
-
* @mongoose
|
|
22
|
-
* @property
|
|
23
|
-
*/
|
|
24
|
-
function Uppercase(uppercase = true) {
|
|
25
|
-
return (0, schema_js_1.MongooseSchema)({ uppercase });
|
|
26
|
-
}
|
|
27
|
-
exports.Uppercase = Uppercase;
|
|
28
|
-
//# sourceMappingURL=uppercase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"uppercase.js","sourceRoot":"","sources":["../../../src/decorators/uppercase.ts"],"names":[],"mappings":";;;AAAA,2CAA2C;AAE3C;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,SAAS,CAAC,YAAqB,IAAI;IACjD,OAAO,IAAA,0BAAc,EAAC,EAAC,SAAS,EAAQ,CAAC,CAAC;AAC5C,CAAC;AAFD,8BAEC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VersionKey = void 0;
|
|
4
|
-
const core_1 = require("@tsed/core");
|
|
5
|
-
const constants_js_1 = require("../constants/constants.js");
|
|
6
|
-
function VersionKey() {
|
|
7
|
-
return (target, propertyKey) => {
|
|
8
|
-
core_1.Store.from(target).merge(constants_js_1.MONGOOSE_SCHEMA_OPTIONS, { versionKey: propertyKey });
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
exports.VersionKey = VersionKey;
|
|
12
|
-
//# sourceMappingURL=versionKey.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"versionKey.js","sourceRoot":"","sources":["../../../src/decorators/versionKey.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AACjC,4DAAkE;AAElE,SAAgB,UAAU;IACxB,OAAO,CAAC,MAAW,EAAE,WAAmB,EAAE,EAAE;QAC1C,YAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,sCAAuB,EAAE,EAAC,UAAU,EAAE,WAAW,EAAC,CAAC,CAAC;IAC/E,CAAC,CAAC;AACJ,CAAC;AAJD,gCAIC"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VirtualRef = void 0;
|
|
4
|
-
const core_1 = require("@tsed/core");
|
|
5
|
-
const schema_1 = require("@tsed/schema");
|
|
6
|
-
const constants_js_1 = require("../constants/constants.js");
|
|
7
|
-
const MongooseModels_js_1 = require("../registries/MongooseModels.js");
|
|
8
|
-
function getRef(opts) {
|
|
9
|
-
const ref = opts.ref;
|
|
10
|
-
return (0, core_1.isString)(ref) ? ref : core_1.Store.from(ref).get(constants_js_1.MONGOOSE_MODEL_NAME);
|
|
11
|
-
}
|
|
12
|
-
function getType(opts) {
|
|
13
|
-
const ref = opts.ref;
|
|
14
|
-
return !(0, core_1.isString)(ref) ? ref : MongooseModels_js_1.MongooseModels.get(ref) || (() => MongooseModels_js_1.MongooseModels.get(ref) || Object);
|
|
15
|
-
}
|
|
16
|
-
function getInitialOpts(options, foreignField) {
|
|
17
|
-
return (0, core_1.isPlainObject)(options) ? options : { ref: options, foreignField };
|
|
18
|
-
}
|
|
19
|
-
function mapToSchema(opts) {
|
|
20
|
-
const ref = getRef(opts);
|
|
21
|
-
const schema = {
|
|
22
|
-
ref,
|
|
23
|
-
localField: opts.localField || "_id",
|
|
24
|
-
foreignField: opts.foreignField,
|
|
25
|
-
justOne: opts.justOne || false,
|
|
26
|
-
count: opts.count || false,
|
|
27
|
-
options: opts.options
|
|
28
|
-
};
|
|
29
|
-
return schema;
|
|
30
|
-
}
|
|
31
|
-
function VirtualRef(options, foreignField) {
|
|
32
|
-
const opts = getInitialOpts(options, foreignField);
|
|
33
|
-
const schema = mapToSchema(opts);
|
|
34
|
-
const type = getType(opts);
|
|
35
|
-
return (0, core_1.useDecorators)((0, core_1.StoreMerge)(constants_js_1.MONGOOSE_SCHEMA, schema), schema.count ? (0, schema_1.Property)(Number) : type && (schema.justOne ? (0, schema_1.Property)(type) : (0, schema_1.CollectionOf)(type, Array)));
|
|
36
|
-
}
|
|
37
|
-
exports.VirtualRef = VirtualRef;
|
|
38
|
-
//# sourceMappingURL=virtualRef.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"virtualRef.js","sourceRoot":"","sources":["../../../src/decorators/virtualRef.ts"],"names":[],"mappings":";;;AAAA,qCAAqF;AACrF,yCAAoD;AACpD,4DAA+E;AAE/E,uEAA+D;AAE/D,SAAS,MAAM,CAAC,IAAS;IACvB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;IAErB,OAAO,IAAA,eAAQ,EAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,YAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,kCAAmB,CAAC,CAAC;AACxE,CAAC;AAED,SAAS,OAAO,CAAC,IAAS;IACxB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;IACrB,OAAO,CAAC,IAAA,eAAQ,EAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,kCAAc,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,kCAAc,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,CAAC;AACrG,CAAC;AAED,SAAS,cAAc,CAAC,OAA2C,EAAE,YAAqB;IACxF,OAAO,IAAA,oBAAa,EAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAC,GAAG,EAAE,OAAc,EAAE,YAAY,EAAC,CAAC;AAChF,CAAC;AAED,SAAS,WAAW,CAAC,IAAS;IAC5B,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAEzB,MAAM,MAAM,GAAQ;QAClB,GAAG;QACH,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,KAAK;QACpC,YAAY,EAAE,IAAI,CAAC,YAAY;QAC/B,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