@tsed/mongoose 7.0.0-alpha.1 → 7.0.0-beta.3
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/jest.config.js +14 -0
- package/lib/cjs/MongooseModule.js +36 -0
- package/lib/cjs/MongooseModule.js.map +1 -0
- package/lib/cjs/constants/index.js +24 -0
- package/lib/cjs/constants/index.js.map +1 -0
- package/lib/cjs/decorators/auto.js +28 -0
- package/lib/cjs/decorators/auto.js.map +1 -0
- package/lib/cjs/decorators/discriminatorKey.js +14 -0
- package/lib/cjs/decorators/discriminatorKey.js.map +1 -0
- package/lib/cjs/decorators/dynamicRef.js +46 -0
- package/lib/cjs/decorators/dynamicRef.js.map +1 -0
- package/lib/cjs/decorators/excludeIndexes.js +28 -0
- package/lib/cjs/decorators/excludeIndexes.js.map +1 -0
- package/lib/cjs/decorators/expires.js +28 -0
- package/lib/cjs/decorators/expires.js.map +1 -0
- package/lib/cjs/decorators/immutable.js +30 -0
- package/lib/cjs/decorators/immutable.js.map +1 -0
- package/lib/cjs/decorators/index.js +30 -0
- package/lib/cjs/decorators/index.js.map +1 -0
- package/lib/cjs/decorators/indexed.js +26 -0
- package/lib/cjs/decorators/indexed.js.map +1 -0
- package/lib/cjs/decorators/lowercase.js +28 -0
- package/lib/cjs/decorators/lowercase.js.map +1 -0
- package/lib/cjs/decorators/model.js +67 -0
- package/lib/cjs/decorators/model.js.map +1 -0
- package/lib/cjs/decorators/mongooseIndex.js +39 -0
- package/lib/cjs/decorators/mongooseIndex.js.map +1 -0
- package/lib/cjs/decorators/mongooseIndexes.js +39 -0
- package/lib/cjs/decorators/mongooseIndexes.js.map +1 -0
- package/lib/cjs/decorators/mongoosePlugin.js +22 -0
- package/lib/cjs/decorators/mongoosePlugin.js.map +1 -0
- package/lib/cjs/decorators/numberDecimal.js +78 -0
- package/lib/cjs/decorators/numberDecimal.js.map +1 -0
- package/lib/cjs/decorators/objectID.js +26 -0
- package/lib/cjs/decorators/objectID.js.map +1 -0
- package/lib/cjs/decorators/postHook.js +26 -0
- package/lib/cjs/decorators/postHook.js.map +1 -0
- package/lib/cjs/decorators/preHook.js +71 -0
- package/lib/cjs/decorators/preHook.js.map +1 -0
- package/lib/cjs/decorators/ref.js +75 -0
- package/lib/cjs/decorators/ref.js.map +1 -0
- package/lib/cjs/decorators/schema.js +32 -0
- package/lib/cjs/decorators/schema.js.map +1 -0
- package/lib/cjs/decorators/schemaIgnore.js +27 -0
- package/lib/cjs/decorators/schemaIgnore.js.map +1 -0
- package/lib/cjs/decorators/select.js +28 -0
- package/lib/cjs/decorators/select.js.map +1 -0
- package/lib/cjs/decorators/sparse.js +30 -0
- package/lib/cjs/decorators/sparse.js.map +1 -0
- package/lib/cjs/decorators/text.js +29 -0
- package/lib/cjs/decorators/text.js.map +1 -0
- package/lib/cjs/decorators/trim.js +27 -0
- package/lib/cjs/decorators/trim.js.map +1 -0
- package/lib/cjs/decorators/unique.js +27 -0
- package/lib/cjs/decorators/unique.js.map +1 -0
- package/lib/cjs/decorators/uppercase.js +28 -0
- package/lib/cjs/decorators/uppercase.js.map +1 -0
- package/lib/cjs/decorators/versionKey.js +12 -0
- package/lib/cjs/decorators/versionKey.js.map +1 -0
- package/lib/cjs/decorators/virtualRef.js +38 -0
- package/lib/cjs/decorators/virtualRef.js.map +1 -0
- package/lib/cjs/index.js +10 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/interfaces/MongooseConnectionOptions.js +3 -0
- package/lib/cjs/interfaces/MongooseConnectionOptions.js.map +1 -0
- package/lib/cjs/interfaces/MongooseDocument.js +3 -0
- package/lib/cjs/interfaces/MongooseDocument.js.map +1 -0
- package/lib/cjs/interfaces/MongooseModel.js +3 -0
- package/lib/cjs/interfaces/MongooseModel.js.map +1 -0
- package/lib/cjs/interfaces/MongooseModelOptions.js +3 -0
- package/lib/cjs/interfaces/MongooseModelOptions.js.map +1 -0
- package/lib/cjs/interfaces/MongooseSchemaOptions.js +3 -0
- package/lib/cjs/interfaces/MongooseSchemaOptions.js.map +1 -0
- package/lib/cjs/interfaces/MongooseSchemaTypes.js +10 -0
- package/lib/cjs/interfaces/MongooseSchemaTypes.js.map +1 -0
- package/lib/cjs/interfaces/MongooseVirtualRefOptions.js +3 -0
- package/lib/cjs/interfaces/MongooseVirtualRefOptions.js.map +1 -0
- package/lib/cjs/interfaces/index.js +10 -0
- package/lib/cjs/interfaces/index.js.map +1 -0
- package/lib/cjs/registries/MongooseModels.js +5 -0
- package/lib/cjs/registries/MongooseModels.js.map +1 -0
- package/lib/cjs/services/MongooseConnections.js +51 -0
- package/lib/cjs/services/MongooseConnections.js.map +1 -0
- package/lib/cjs/services/MongooseService.js +73 -0
- package/lib/cjs/services/MongooseService.js.map +1 -0
- package/lib/cjs/utils/createModel.js +58 -0
- package/lib/cjs/utils/createModel.js.map +1 -0
- package/lib/cjs/utils/createSchema.js +160 -0
- package/lib/cjs/utils/createSchema.js.map +1 -0
- package/lib/cjs/utils/index.js +6 -0
- package/lib/cjs/utils/index.js.map +1 -0
- package/lib/cjs/utils/resolveRefType.js +19 -0
- package/lib/cjs/utils/resolveRefType.js.map +1 -0
- package/lib/cjs/utils/schemaOptions.js +60 -0
- package/lib/cjs/utils/schemaOptions.js.map +1 -0
- package/lib/esm/MongooseModule.js +33 -0
- package/lib/esm/MongooseModule.js.map +1 -0
- package/lib/esm/constants/index.js +21 -0
- package/lib/esm/constants/index.js.map +1 -0
- package/lib/esm/decorators/auto.js +24 -0
- package/lib/esm/decorators/auto.js.map +1 -0
- package/lib/esm/decorators/discriminatorKey.js +10 -0
- package/lib/esm/decorators/discriminatorKey.js.map +1 -0
- package/lib/esm/decorators/dynamicRef.js +42 -0
- package/lib/esm/decorators/dynamicRef.js.map +1 -0
- package/lib/esm/decorators/excludeIndexes.js +24 -0
- package/lib/esm/decorators/excludeIndexes.js.map +1 -0
- package/lib/esm/decorators/expires.js +24 -0
- package/lib/esm/decorators/expires.js.map +1 -0
- package/lib/esm/decorators/immutable.js +26 -0
- package/lib/esm/decorators/immutable.js.map +1 -0
- package/lib/esm/decorators/index.js +27 -0
- package/lib/esm/decorators/index.js.map +1 -0
- package/lib/esm/decorators/indexed.js +22 -0
- package/lib/esm/decorators/indexed.js.map +1 -0
- package/lib/esm/decorators/lowercase.js +24 -0
- package/lib/esm/decorators/lowercase.js.map +1 -0
- package/lib/esm/decorators/model.js +63 -0
- package/lib/esm/decorators/model.js.map +1 -0
- package/lib/esm/decorators/mongooseIndex.js +35 -0
- package/lib/esm/decorators/mongooseIndex.js.map +1 -0
- package/lib/esm/decorators/mongooseIndexes.js +35 -0
- package/lib/esm/decorators/mongooseIndexes.js.map +1 -0
- package/lib/esm/decorators/mongoosePlugin.js +18 -0
- package/lib/esm/decorators/mongoosePlugin.js.map +1 -0
- package/lib/esm/decorators/numberDecimal.js +74 -0
- package/lib/esm/decorators/numberDecimal.js.map +1 -0
- package/lib/esm/decorators/objectID.js +22 -0
- package/lib/esm/decorators/objectID.js.map +1 -0
- package/lib/esm/decorators/postHook.js +22 -0
- package/lib/esm/decorators/postHook.js.map +1 -0
- package/lib/esm/decorators/preHook.js +67 -0
- package/lib/esm/decorators/preHook.js.map +1 -0
- package/lib/esm/decorators/ref.js +71 -0
- package/lib/esm/decorators/ref.js.map +1 -0
- package/lib/esm/decorators/schema.js +27 -0
- package/lib/esm/decorators/schema.js.map +1 -0
- package/lib/esm/decorators/schemaIgnore.js +23 -0
- package/lib/esm/decorators/schemaIgnore.js.map +1 -0
- package/lib/esm/decorators/select.js +24 -0
- package/lib/esm/decorators/select.js.map +1 -0
- package/lib/esm/decorators/sparse.js +26 -0
- package/lib/esm/decorators/sparse.js.map +1 -0
- package/lib/esm/decorators/text.js +25 -0
- package/lib/esm/decorators/text.js.map +1 -0
- package/lib/esm/decorators/trim.js +23 -0
- package/lib/esm/decorators/trim.js.map +1 -0
- package/lib/esm/decorators/unique.js +23 -0
- package/lib/esm/decorators/unique.js.map +1 -0
- package/lib/esm/decorators/uppercase.js +24 -0
- package/lib/esm/decorators/uppercase.js.map +1 -0
- package/lib/esm/decorators/versionKey.js +8 -0
- package/lib/esm/decorators/versionKey.js.map +1 -0
- package/lib/esm/decorators/virtualRef.js +34 -0
- package/lib/esm/decorators/virtualRef.js.map +1 -0
- package/lib/esm/index.js +7 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/interfaces/MongooseConnectionOptions.js +2 -0
- package/lib/esm/interfaces/MongooseConnectionOptions.js.map +1 -0
- package/lib/esm/interfaces/MongooseDocument.js +2 -0
- package/lib/esm/interfaces/MongooseDocument.js.map +1 -0
- package/lib/esm/interfaces/MongooseModel.js +2 -0
- package/lib/esm/interfaces/MongooseModel.js.map +1 -0
- package/lib/esm/interfaces/MongooseModelOptions.js +2 -0
- package/lib/esm/interfaces/MongooseModelOptions.js.map +1 -0
- package/lib/esm/interfaces/MongooseSchemaOptions.js +2 -0
- package/lib/esm/interfaces/MongooseSchemaOptions.js.map +1 -0
- package/lib/esm/interfaces/MongooseSchemaTypes.js +7 -0
- package/lib/esm/interfaces/MongooseSchemaTypes.js.map +1 -0
- package/lib/esm/interfaces/MongooseVirtualRefOptions.js +2 -0
- package/lib/esm/interfaces/MongooseVirtualRefOptions.js.map +1 -0
- package/lib/esm/interfaces/index.js +7 -0
- package/lib/esm/interfaces/index.js.map +1 -0
- package/lib/esm/registries/MongooseModels.js +2 -0
- package/lib/esm/registries/MongooseModels.js.map +1 -0
- package/lib/esm/services/MongooseConnections.js +48 -0
- package/lib/esm/services/MongooseConnections.js.map +1 -0
- package/lib/esm/services/MongooseService.js +70 -0
- package/lib/esm/services/MongooseService.js.map +1 -0
- package/lib/esm/utils/createModel.js +52 -0
- package/lib/esm/utils/createModel.js.map +1 -0
- package/lib/esm/utils/createSchema.js +151 -0
- package/lib/esm/utils/createSchema.js.map +1 -0
- package/lib/esm/utils/index.js +3 -0
- package/lib/esm/utils/index.js.map +1 -0
- package/lib/esm/utils/resolveRefType.js +15 -0
- package/lib/esm/utils/resolveRefType.js.map +1 -0
- package/lib/esm/utils/schemaOptions.js +54 -0
- package/lib/esm/utils/schemaOptions.js.map +1 -0
- package/lib/{MongooseModule.d.ts → types/MongooseModule.d.ts} +0 -0
- package/lib/{constants → types/constants}/index.d.ts +0 -0
- package/lib/{decorators → types/decorators}/auto.d.ts +0 -0
- package/lib/{decorators → types/decorators}/discriminatorKey.d.ts +0 -0
- package/lib/{decorators → types/decorators}/dynamicRef.d.ts +0 -0
- package/lib/{decorators → types/decorators}/excludeIndexes.d.ts +0 -0
- package/lib/{decorators → types/decorators}/expires.d.ts +0 -0
- package/lib/{decorators → types/decorators}/immutable.d.ts +0 -0
- package/lib/{decorators → types/decorators}/index.d.ts +0 -0
- package/lib/{decorators → types/decorators}/indexed.d.ts +0 -0
- package/lib/{decorators → types/decorators}/lowercase.d.ts +0 -0
- package/lib/{decorators → types/decorators}/model.d.ts +0 -0
- package/lib/{decorators → types/decorators}/mongooseIndex.d.ts +0 -0
- package/lib/types/decorators/mongooseIndexes.d.ts +32 -0
- package/lib/{decorators → types/decorators}/mongoosePlugin.d.ts +0 -0
- package/lib/{decorators → types/decorators}/numberDecimal.d.ts +0 -0
- package/lib/{decorators → types/decorators}/objectID.d.ts +0 -0
- package/lib/{decorators → types/decorators}/postHook.d.ts +0 -0
- package/lib/{decorators → types/decorators}/preHook.d.ts +0 -0
- package/lib/{decorators → types/decorators}/ref.d.ts +7 -2
- package/lib/{decorators → types/decorators}/schema.d.ts +0 -0
- package/lib/{decorators → types/decorators}/schemaIgnore.d.ts +0 -0
- package/lib/{decorators → types/decorators}/select.d.ts +0 -0
- package/lib/{decorators → types/decorators}/sparse.d.ts +0 -0
- package/lib/{decorators → types/decorators}/text.d.ts +0 -0
- package/lib/{decorators → types/decorators}/trim.d.ts +0 -0
- package/lib/{decorators → types/decorators}/unique.d.ts +0 -0
- package/lib/{decorators → types/decorators}/uppercase.d.ts +0 -0
- package/lib/{decorators → types/decorators}/versionKey.d.ts +0 -0
- package/lib/{decorators → types/decorators}/virtualRef.d.ts +0 -0
- package/lib/{index.d.ts → types/index.d.ts} +0 -0
- package/lib/{interfaces → types/interfaces}/MongooseConnectionOptions.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/MongooseDocument.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/MongooseModel.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/MongooseModelOptions.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/MongooseSchemaOptions.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/MongooseSchemaTypes.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/MongooseVirtualRefOptions.d.ts +1 -0
- package/lib/{interfaces → types/interfaces}/index.d.ts +0 -0
- package/lib/{registries → types/registries}/MongooseModels.d.ts +0 -0
- package/lib/{services → types/services}/MongooseConnections.d.ts +0 -0
- package/lib/{services → types/services}/MongooseService.d.ts +0 -0
- package/lib/{utils → types/utils}/createModel.d.ts +2 -1
- package/lib/{utils → types/utils}/createSchema.d.ts +0 -0
- package/lib/{utils → types/utils}/index.d.ts +0 -0
- package/lib/{utils → types/utils}/resolveRefType.d.ts +0 -0
- package/lib/{utils → types/utils}/schemaOptions.d.ts +0 -0
- package/package.json +25 -21
- package/tsconfig.compile.esm.json +23 -0
- package/.mocharc.js +0 -5
- package/.nycrc +0 -27
- package/lib/index.js +0 -1402
- package/lib/index.js.map +0 -1
- package/lib/index.modern.js +0 -1362
- package/lib/index.modern.js.map +0 -1
package/jest.config.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// For a detailed explanation regarding each configuration property, visit:
|
|
2
|
+
// https://jestjs.io/docs/en/configuration.html
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
...require("@tsed/jest-config")(__dirname, "mongoose"),
|
|
6
|
+
coverageThreshold: {
|
|
7
|
+
global: {
|
|
8
|
+
branches: 94.67,
|
|
9
|
+
functions: 98.9,
|
|
10
|
+
lines: 98.9,
|
|
11
|
+
statements: 98.93
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MongooseModule = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const di_1 = require("@tsed/di");
|
|
6
|
+
const di_2 = require("@tsed/di");
|
|
7
|
+
const MongooseConnections_1 = require("./services/MongooseConnections");
|
|
8
|
+
const MongooseService_1 = require("./services/MongooseService");
|
|
9
|
+
/**
|
|
10
|
+
* @ignore
|
|
11
|
+
*/
|
|
12
|
+
let MongooseModule = class MongooseModule {
|
|
13
|
+
constructor(mongooseService, settings) {
|
|
14
|
+
this.mongooseService = mongooseService;
|
|
15
|
+
this.settings = settings;
|
|
16
|
+
// auto configure the cache manager when mongoose is used with @tsed/mongoose
|
|
17
|
+
const cache = this.settings.get("cache");
|
|
18
|
+
// istanbul ignore next
|
|
19
|
+
if (cache === null || cache === void 0 ? void 0 : cache.mongoose) {
|
|
20
|
+
cache.connection = this.mongooseService.get();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
$onInit() { }
|
|
24
|
+
$onDestroy() {
|
|
25
|
+
return this.mongooseService.closeConnections();
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
MongooseModule = (0, tslib_1.__decorate)([
|
|
29
|
+
(0, di_2.Module)({
|
|
30
|
+
imports: [MongooseConnections_1.MONGOOSE_CONNECTIONS]
|
|
31
|
+
}),
|
|
32
|
+
(0, tslib_1.__param)(1, (0, di_1.Configuration)()),
|
|
33
|
+
(0, tslib_1.__metadata)("design:paramtypes", [MongooseService_1.MongooseService, Object])
|
|
34
|
+
], MongooseModule);
|
|
35
|
+
exports.MongooseModule = MongooseModule;
|
|
36
|
+
//# sourceMappingURL=MongooseModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MongooseModule.js","sourceRoot":"","sources":["../../src/MongooseModule.ts"],"names":[],"mappings":";;;;AAAA,iCAA+C;AAC/C,iCAA2C;AAC3C,wEAAoE;AACpE,gEAA2D;AAE3D;;GAEG;AAIH,IAAa,cAAc,GAA3B,MAAa,cAAc;IACzB,YAAoB,eAAgC,EAA2B,QAAuB;QAAlF,oBAAe,GAAf,eAAe,CAAiB;QAA2B,aAAQ,GAAR,QAAQ,CAAe;QACpG,6EAA6E;QAC7E,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAM,OAAO,CAAC,CAAC;QAE9C,uBAAuB;QACvB,IAAI,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,EAAE;YACnB,KAAK,CAAC,UAAU,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,EAAE,CAAC;SAC/C;IACH,CAAC;IAED,OAAO,KAAyB,CAAC;IAEjC,UAAU;QACR,OAAO,IAAI,CAAC,eAAe,CAAC,gBAAgB,EAAE,CAAC;IACjD,CAAC;CACF,CAAA;AAhBY,cAAc;IAH1B,IAAA,WAAM,EAAC;QACN,OAAO,EAAE,CAAC,0CAAoB,CAAC;KAChC,CAAC;IAEuD,wBAAA,IAAA,kBAAa,GAAE,CAAA;kDAAjC,iCAAe;GADzC,cAAc,CAgB1B;AAhBY,wCAAc","sourcesContent":["import {Configuration, OnInit} from \"@tsed/di\";\nimport {Module, OnDestroy} from \"@tsed/di\";\nimport {MONGOOSE_CONNECTIONS} from \"./services/MongooseConnections\";\nimport {MongooseService} from \"./services/MongooseService\";\n\n/**\n * @ignore\n */\n@Module({\n imports: [MONGOOSE_CONNECTIONS]\n})\nexport class MongooseModule implements OnDestroy, OnInit {\n constructor(private mongooseService: MongooseService, @Configuration() private settings: Configuration) {\n // auto configure the cache manager when mongoose is used with @tsed/mongoose\n const cache = this.settings.get<any>(\"cache\");\n\n // istanbul ignore next\n if (cache?.mongoose) {\n cache.connection = this.mongooseService.get();\n }\n }\n\n $onInit(): void | Promise<any> {}\n\n $onDestroy(): Promise<any> | void {\n return this.mongooseService.closeConnections();\n }\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MONGOOSE_MODEL_NAME = exports.MONGOOSE_MODEL = exports.MONGOOSE_SCHEMA_OPTIONS = exports.MONGOOSE_SCHEMA = void 0;
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @type {string}
|
|
7
|
+
*/
|
|
8
|
+
exports.MONGOOSE_SCHEMA = "tsed:mongoose:schema";
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @type {string}
|
|
12
|
+
*/
|
|
13
|
+
exports.MONGOOSE_SCHEMA_OPTIONS = "tsed:mongoose:schema:options";
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @type {string}
|
|
17
|
+
*/
|
|
18
|
+
exports.MONGOOSE_MODEL = "tsed:mongoose:model";
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @type {string}
|
|
22
|
+
*/
|
|
23
|
+
exports.MONGOOSE_MODEL_NAME = "tsed:mongoose:model:name";
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/constants/index.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACU,QAAA,eAAe,GAAG,sBAAsB,CAAC;AACtD;;;GAGG;AACU,QAAA,uBAAuB,GAAG,8BAA8B,CAAC;AACtE;;;GAGG;AACU,QAAA,cAAc,GAAG,qBAAqB,CAAC;AACpD;;;GAGG;AACU,QAAA,mBAAmB,GAAG,0BAA0B,CAAC","sourcesContent":["/**\n *\n * @type {string}\n */\nexport const MONGOOSE_SCHEMA = \"tsed:mongoose:schema\";\n/**\n *\n * @type {string}\n */\nexport const MONGOOSE_SCHEMA_OPTIONS = \"tsed:mongoose:schema:options\";\n/**\n *\n * @type {string}\n */\nexport const MONGOOSE_MODEL = \"tsed:mongoose:model\";\n/**\n *\n * @type {string}\n */\nexport const MONGOOSE_MODEL_NAME = \"tsed:mongoose:model:name\";\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Auto = void 0;
|
|
4
|
+
const schema_1 = require("./schema");
|
|
5
|
+
/**
|
|
6
|
+
* If true, uses Mongoose's default _id settings. Only allowed for ObjectIds
|
|
7
|
+
*
|
|
8
|
+
* ### Example
|
|
9
|
+
*
|
|
10
|
+
* ```typescript
|
|
11
|
+
* @Model()
|
|
12
|
+
* export class EventModel {
|
|
13
|
+
* @ExcludeIndexes()
|
|
14
|
+
* field: string;
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @param {boolean} auto
|
|
19
|
+
* @returns {Function}
|
|
20
|
+
* @decorator
|
|
21
|
+
* @mongoose
|
|
22
|
+
* @property
|
|
23
|
+
*/
|
|
24
|
+
function Auto(auto = true) {
|
|
25
|
+
return (0, schema_1.MongooseSchema)({ auto });
|
|
26
|
+
}
|
|
27
|
+
exports.Auto = Auto;
|
|
28
|
+
//# sourceMappingURL=auto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto.js","sourceRoot":"","sources":["../../../src/decorators/auto.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AAExC;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,IAAI,CAAC,OAAgB,IAAI;IACvC,OAAO,IAAA,uBAAc,EAAC,EAAC,IAAI,EAAQ,CAAC,CAAC;AACvC,CAAC;AAFD,oBAEC","sourcesContent":["import {MongooseSchema} from \"./schema\";\n\n/**\n * If true, uses Mongoose's default _id settings. Only allowed for ObjectIds\n *\n * ### Example\n *\n * ```typescript\n * @Model()\n * export class EventModel {\n * @ExcludeIndexes()\n * field: string;\n * }\n * ```\n *\n * @param {boolean} auto\n * @returns {Function}\n * @decorator\n * @mongoose\n * @property\n */\nexport function Auto(auto: boolean = true): PropertyDecorator {\n return MongooseSchema({auto} as any);\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DiscriminatorKey = void 0;
|
|
4
|
+
const core_1 = require("@tsed/core");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
const schemaIgnore_1 = require("./schemaIgnore");
|
|
7
|
+
const schema_1 = require("@tsed/schema");
|
|
8
|
+
function DiscriminatorKey() {
|
|
9
|
+
return (0, core_1.useDecorators)((0, schema_1.Property)(), (0, schemaIgnore_1.SchemaIgnore)(), (target, propertyKey) => {
|
|
10
|
+
core_1.Store.from(target).merge(constants_1.MONGOOSE_SCHEMA_OPTIONS, { discriminatorKey: propertyKey });
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
exports.DiscriminatorKey = DiscriminatorKey;
|
|
14
|
+
//# sourceMappingURL=discriminatorKey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discriminatorKey.js","sourceRoot":"","sources":["../../../src/decorators/discriminatorKey.ts"],"names":[],"mappings":";;;AAAA,qCAAgD;AAChD,4CAAqD;AACrD,iDAA4C;AAC5C,yCAAsC;AAEtC,SAAgB,gBAAgB;IAC9B,OAAO,IAAA,oBAAa,EAAC,IAAA,iBAAQ,GAAE,EAAE,IAAA,2BAAY,GAAE,EAAE,CAAC,MAAW,EAAE,WAAmB,EAAE,EAAE;QACpF,YAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,mCAAuB,EAAE,EAAC,gBAAgB,EAAE,WAAW,EAAC,CAAC,CAAC;IACrF,CAAC,CAAC,CAAC;AACL,CAAC;AAJD,4CAIC","sourcesContent":["import {Store, useDecorators} from \"@tsed/core\";\nimport {MONGOOSE_SCHEMA_OPTIONS} from \"../constants\";\nimport {SchemaIgnore} from \"./schemaIgnore\";\nimport {Property} from \"@tsed/schema\";\n\nexport function DiscriminatorKey(): PropertyDecorator {\n return useDecorators(Property(), SchemaIgnore(), (target: any, propertyKey: string) => {\n Store.from(target).merge(MONGOOSE_SCHEMA_OPTIONS, {discriminatorKey: propertyKey});\n });\n}\n"]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DynamicRef = void 0;
|
|
4
|
+
const core_1 = require("@tsed/core");
|
|
5
|
+
const schema_1 = require("@tsed/schema");
|
|
6
|
+
const mongoose_1 = require("mongoose");
|
|
7
|
+
const constants_1 = require("../constants");
|
|
8
|
+
/**
|
|
9
|
+
* Define a property as mongoose reference to other Model (decorated with @Model).
|
|
10
|
+
*
|
|
11
|
+
* ### Example
|
|
12
|
+
*
|
|
13
|
+
* ```typescript
|
|
14
|
+
* @Model()
|
|
15
|
+
* class FooModel {
|
|
16
|
+
*
|
|
17
|
+
* @DynamicRef('type')
|
|
18
|
+
* field: DynamicRef<OtherFooModel | OtherModel>
|
|
19
|
+
*
|
|
20
|
+
* @Enum(['OtherFooModel', 'OtherModel'])
|
|
21
|
+
* type: string
|
|
22
|
+
* }
|
|
23
|
+
*
|
|
24
|
+
* @Model()
|
|
25
|
+
* class OtherFooModel {
|
|
26
|
+
* }
|
|
27
|
+
*
|
|
28
|
+
* @Model()
|
|
29
|
+
* class OtherModel {
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @param refPath
|
|
34
|
+
* @returns {Function}
|
|
35
|
+
* @decorator
|
|
36
|
+
* @mongoose
|
|
37
|
+
* @property
|
|
38
|
+
*/
|
|
39
|
+
function DynamicRef(refPath) {
|
|
40
|
+
return (0, core_1.useDecorators)((0, schema_1.Property)(String), (0, schema_1.Example)("5ce7ad3028890bd71749d477"), (0, schema_1.Description)("Mongoose Ref ObjectId"), (0, core_1.StoreMerge)(constants_1.MONGOOSE_SCHEMA, {
|
|
41
|
+
type: mongoose_1.Schema.Types.ObjectId,
|
|
42
|
+
refPath
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
exports.DynamicRef = DynamicRef;
|
|
46
|
+
//# sourceMappingURL=dynamicRef.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamicRef.js","sourceRoot":"","sources":["../../../src/decorators/dynamicRef.ts"],"names":[],"mappings":";;;AAAA,qCAAqD;AACrD,yCAA4D;AAC5D,uCAAkD;AAClD,4CAA6C;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,SAAgB,UAAU,CAAC,OAAe;IACxC,OAAO,IAAA,oBAAa,EAClB,IAAA,iBAAQ,EAAC,MAAM,CAAC,EAChB,IAAA,gBAAO,EAAC,0BAA0B,CAAC,EACnC,IAAA,oBAAW,EAAC,uBAAuB,CAAC,EACpC,IAAA,iBAAU,EAAC,2BAAe,EAAE;QAC1B,IAAI,EAAE,iBAAc,CAAC,KAAK,CAAC,QAAQ;QACnC,OAAO;KACR,CAAC,CACkB,CAAC;AACzB,CAAC;AAVD,gCAUC","sourcesContent":["import {StoreMerge, useDecorators} from \"@tsed/core\";\nimport {Description, Example, Property} from \"@tsed/schema\";\nimport {Schema as MongooseSchema} from \"mongoose\";\nimport {MONGOOSE_SCHEMA} from \"../constants\";\n\n/**\n * Define a property as mongoose reference to other Model (decorated with @Model).\n *\n * ### Example\n *\n * ```typescript\n * @Model()\n * class FooModel {\n *\n * @DynamicRef('type')\n * field: DynamicRef<OtherFooModel | OtherModel>\n *\n * @Enum(['OtherFooModel', 'OtherModel'])\n * type: string\n * }\n *\n * @Model()\n * class OtherFooModel {\n * }\n *\n * @Model()\n * class OtherModel {\n * }\n * ```\n *\n * @param refPath\n * @returns {Function}\n * @decorator\n * @mongoose\n * @property\n */\nexport function DynamicRef(refPath: string): PropertyDecorator {\n return useDecorators(\n Property(String),\n Example(\"5ce7ad3028890bd71749d477\"),\n Description(\"Mongoose Ref ObjectId\"),\n StoreMerge(MONGOOSE_SCHEMA, {\n type: MongooseSchema.Types.ObjectId,\n refPath\n })\n ) as PropertyDecorator;\n}\n\nexport type DynamicRef<T> = T | string;\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExcludeIndexes = void 0;
|
|
4
|
+
const schema_1 = require("./schema");
|
|
5
|
+
/**
|
|
6
|
+
* If true, Mongoose will skip gathering indexes on subpaths. Only allowed for subdocuments and subdocument arrays.
|
|
7
|
+
*
|
|
8
|
+
* ### Example
|
|
9
|
+
*
|
|
10
|
+
* ```typescript
|
|
11
|
+
* @Model()
|
|
12
|
+
* export class EventModel {
|
|
13
|
+
* @ExcludeIndexes()
|
|
14
|
+
* field: string;
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @param {boolean} excludeIndexes
|
|
19
|
+
* @returns {Function}
|
|
20
|
+
* @decorator
|
|
21
|
+
* @mongoose
|
|
22
|
+
* @property
|
|
23
|
+
*/
|
|
24
|
+
function ExcludeIndexes(excludeIndexes = true) {
|
|
25
|
+
return (0, schema_1.MongooseSchema)({ excludeIndexes });
|
|
26
|
+
}
|
|
27
|
+
exports.ExcludeIndexes = ExcludeIndexes;
|
|
28
|
+
//# sourceMappingURL=excludeIndexes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"excludeIndexes.js","sourceRoot":"","sources":["../../../src/decorators/excludeIndexes.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AAExC;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,cAAc,CAAC,iBAA0B,IAAI;IAC3D,OAAO,IAAA,uBAAc,EAAC,EAAC,cAAc,EAAQ,CAAC,CAAC;AACjD,CAAC;AAFD,wCAEC","sourcesContent":["import {MongooseSchema} from \"./schema\";\n\n/**\n * If true, Mongoose will skip gathering indexes on subpaths. Only allowed for subdocuments and subdocument arrays.\n *\n * ### Example\n *\n * ```typescript\n * @Model()\n * export class EventModel {\n * @ExcludeIndexes()\n * field: string;\n * }\n * ```\n *\n * @param {boolean} excludeIndexes\n * @returns {Function}\n * @decorator\n * @mongoose\n * @property\n */\nexport function ExcludeIndexes(excludeIndexes: boolean = true): PropertyDecorator {\n return MongooseSchema({excludeIndexes} as any);\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Expires = void 0;
|
|
4
|
+
const schema_1 = require("./schema");
|
|
5
|
+
/**
|
|
6
|
+
* Defines a TTL index on this path. Only allowed for dates.
|
|
7
|
+
*
|
|
8
|
+
* ### Example
|
|
9
|
+
*
|
|
10
|
+
* ```typescript
|
|
11
|
+
* @Model()
|
|
12
|
+
* export class EventModel {
|
|
13
|
+
* @Expires('5d')
|
|
14
|
+
* field: string;
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @param {boolean | any} expires
|
|
19
|
+
* @returns {Function}
|
|
20
|
+
* @decorator
|
|
21
|
+
* @mongoose
|
|
22
|
+
* @property
|
|
23
|
+
*/
|
|
24
|
+
function Expires(expires) {
|
|
25
|
+
return (0, schema_1.MongooseSchema)({ expires });
|
|
26
|
+
}
|
|
27
|
+
exports.Expires = Expires;
|
|
28
|
+
//# sourceMappingURL=expires.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expires.js","sourceRoot":"","sources":["../../../src/decorators/expires.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AAExC;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,OAAO,CAAC,OAA+B;IACrD,OAAO,IAAA,uBAAc,EAAC,EAAC,OAAO,EAAQ,CAAC,CAAC;AAC1C,CAAC;AAFD,0BAEC","sourcesContent":["import {MongooseSchema} from \"./schema\";\n\n/**\n * Defines a TTL index on this path. Only allowed for dates.\n *\n * ### Example\n *\n * ```typescript\n * @Model()\n * export class EventModel {\n * @Expires('5d')\n * field: string;\n * }\n * ```\n *\n * @param {boolean | any} expires\n * @returns {Function}\n * @decorator\n * @mongoose\n * @property\n */\nexport function Expires(expires: number | string | Date): PropertyDecorator {\n return MongooseSchema({expires} as any);\n}\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Immutable = void 0;
|
|
4
|
+
const schema_1 = require("./schema");
|
|
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
|
+
* @Immutable()
|
|
16
|
+
* field: string;
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @param {boolean | any} immutable
|
|
21
|
+
* @returns {Function}
|
|
22
|
+
* @decorator
|
|
23
|
+
* @mongoose
|
|
24
|
+
* @property
|
|
25
|
+
*/
|
|
26
|
+
function Immutable(immutable = true) {
|
|
27
|
+
return (0, schema_1.MongooseSchema)({ immutable });
|
|
28
|
+
}
|
|
29
|
+
exports.Immutable = Immutable;
|
|
30
|
+
//# sourceMappingURL=immutable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"immutable.js","sourceRoot":"","sources":["../../../src/decorators/immutable.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AAExC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,SAAS,CAAC,YAA0D,IAAI;IACtF,OAAO,IAAA,uBAAc,EAAC,EAAC,SAAS,EAAQ,CAAC,CAAC;AAC5C,CAAC;AAFD,8BAEC","sourcesContent":["import {MongooseSchema} from \"./schema\";\n\n/**\n * If [truthy](https://masteringjs.io/tutorials/fundamentals/truthy), Mongoose will\n * disallow changes to this path once the document is saved to the database for the first time. Read more\n * about [immutability in Mongoose here](http://thecodebarbarian.com/whats-new-in-mongoose-5-6-immutable-properties.html).\n *\n * ### Example\n *\n * ```typescript\n * @Model()\n * export class EventModel {\n * @Immutable()\n * field: string;\n * }\n * ```\n *\n * @param {boolean | any} immutable\n * @returns {Function}\n * @decorator\n * @mongoose\n * @property\n */\nexport function Immutable(immutable: boolean | ((this: any, doc: any) => boolean) = true): PropertyDecorator {\n return MongooseSchema({immutable} as any);\n}\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
(0, tslib_1.__exportStar)(require("./auto"), exports);
|
|
5
|
+
(0, tslib_1.__exportStar)(require("./discriminatorKey"), exports);
|
|
6
|
+
(0, tslib_1.__exportStar)(require("./dynamicRef"), exports);
|
|
7
|
+
(0, tslib_1.__exportStar)(require("./excludeIndexes"), exports);
|
|
8
|
+
(0, tslib_1.__exportStar)(require("./expires"), exports);
|
|
9
|
+
(0, tslib_1.__exportStar)(require("./immutable"), exports);
|
|
10
|
+
(0, tslib_1.__exportStar)(require("./indexed"), exports);
|
|
11
|
+
(0, tslib_1.__exportStar)(require("./lowercase"), exports);
|
|
12
|
+
(0, tslib_1.__exportStar)(require("./model"), exports);
|
|
13
|
+
(0, tslib_1.__exportStar)(require("./mongooseIndex"), exports);
|
|
14
|
+
(0, tslib_1.__exportStar)(require("./mongoosePlugin"), exports);
|
|
15
|
+
(0, tslib_1.__exportStar)(require("./numberDecimal"), exports);
|
|
16
|
+
(0, tslib_1.__exportStar)(require("./objectID"), exports);
|
|
17
|
+
(0, tslib_1.__exportStar)(require("./postHook"), exports);
|
|
18
|
+
(0, tslib_1.__exportStar)(require("./preHook"), exports);
|
|
19
|
+
(0, tslib_1.__exportStar)(require("./ref"), exports);
|
|
20
|
+
(0, tslib_1.__exportStar)(require("./schema"), exports);
|
|
21
|
+
(0, tslib_1.__exportStar)(require("./schemaIgnore"), exports);
|
|
22
|
+
(0, tslib_1.__exportStar)(require("./select"), exports);
|
|
23
|
+
(0, tslib_1.__exportStar)(require("./sparse"), exports);
|
|
24
|
+
(0, tslib_1.__exportStar)(require("./text"), exports);
|
|
25
|
+
(0, tslib_1.__exportStar)(require("./trim"), exports);
|
|
26
|
+
(0, tslib_1.__exportStar)(require("./unique"), exports);
|
|
27
|
+
(0, tslib_1.__exportStar)(require("./uppercase"), exports);
|
|
28
|
+
(0, tslib_1.__exportStar)(require("./versionKey"), exports);
|
|
29
|
+
(0, tslib_1.__exportStar)(require("./virtualRef"), exports);
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/decorators/index.ts"],"names":[],"mappings":";;;AAAA,sDAAuB;AACvB,kEAAmC;AACnC,4DAA6B;AAC7B,gEAAiC;AACjC,yDAA0B;AAC1B,2DAA4B;AAC5B,yDAA0B;AAC1B,2DAA4B;AAC5B,uDAAwB;AACxB,+DAAgC;AAChC,gEAAiC;AACjC,+DAAgC;AAChC,0DAA2B;AAC3B,0DAA2B;AAC3B,yDAA0B;AAC1B,qDAAsB;AACtB,wDAAyB;AACzB,8DAA+B;AAC/B,wDAAyB;AACzB,wDAAyB;AACzB,sDAAuB;AACvB,sDAAuB;AACvB,wDAAyB;AACzB,2DAA4B;AAC5B,4DAA6B;AAC7B,4DAA6B","sourcesContent":["export * from \"./auto\";\nexport * from \"./discriminatorKey\";\nexport * from \"./dynamicRef\";\nexport * from \"./excludeIndexes\";\nexport * from \"./expires\";\nexport * from \"./immutable\";\nexport * from \"./indexed\";\nexport * from \"./lowercase\";\nexport * from \"./model\";\nexport * from \"./mongooseIndex\";\nexport * from \"./mongoosePlugin\";\nexport * from \"./numberDecimal\";\nexport * from \"./objectID\";\nexport * from \"./postHook\";\nexport * from \"./preHook\";\nexport * from \"./ref\";\nexport * from \"./schema\";\nexport * from \"./schemaIgnore\";\nexport * from \"./select\";\nexport * from \"./sparse\";\nexport * from \"./text\";\nexport * from \"./trim\";\nexport * from \"./unique\";\nexport * from \"./uppercase\";\nexport * from \"./versionKey\";\nexport * from \"./virtualRef\";\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Indexed = void 0;
|
|
4
|
+
const schema_1 = require("./schema");
|
|
5
|
+
/**
|
|
6
|
+
* Tell Mongoose whether to define an index for the property.
|
|
7
|
+
* ### Example
|
|
8
|
+
*
|
|
9
|
+
* ```typescript
|
|
10
|
+
* @Model()
|
|
11
|
+
* export class EventModel {
|
|
12
|
+
* @Indexed()
|
|
13
|
+
* field: string;
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @returns {Function}
|
|
18
|
+
* @decorator
|
|
19
|
+
* @mongoose
|
|
20
|
+
* @property
|
|
21
|
+
*/
|
|
22
|
+
function Indexed(index = true) {
|
|
23
|
+
return (0, schema_1.MongooseSchema)({ index });
|
|
24
|
+
}
|
|
25
|
+
exports.Indexed = Indexed;
|
|
26
|
+
//# sourceMappingURL=indexed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexed.js","sourceRoot":"","sources":["../../../src/decorators/indexed.ts"],"names":[],"mappings":";;;AACA,qCAAwC;AAExC;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,OAAO,CAAC,QAAyC,IAAI;IACnE,OAAO,IAAA,uBAAc,EAAC,EAAC,KAAK,EAAQ,CAAC,CAAC;AACxC,CAAC;AAFD,0BAEC","sourcesContent":["import {IndexOptions} from \"mongoose\";\nimport {MongooseSchema} from \"./schema\";\n\n/**\n * Tell Mongoose whether to define an index for the property.\n * ### Example\n *\n * ```typescript\n * @Model()\n * export class EventModel {\n * @Indexed()\n * field: string;\n * }\n * ```\n *\n * @returns {Function}\n * @decorator\n * @mongoose\n * @property\n */\nexport function Indexed(index: IndexOptions | boolean | string = true): PropertyDecorator {\n return MongooseSchema({index} as any);\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Lowercase = void 0;
|
|
4
|
+
const schema_1 = require("./schema");
|
|
5
|
+
/**
|
|
6
|
+
* If truthy, Mongoose will add a custom setter that lowercases this string using JavaScript's built-in String#toLowerCase().
|
|
7
|
+
*
|
|
8
|
+
* ### Example
|
|
9
|
+
*
|
|
10
|
+
* ```typescript
|
|
11
|
+
* @Model()
|
|
12
|
+
* export class EventModel {
|
|
13
|
+
* @Lowercase()
|
|
14
|
+
* field: string;
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @param {boolean} lowercase
|
|
19
|
+
* @returns {Function}
|
|
20
|
+
* @decorator
|
|
21
|
+
* @mongoose
|
|
22
|
+
* @property
|
|
23
|
+
*/
|
|
24
|
+
function Lowercase(lowercase = true) {
|
|
25
|
+
return (0, schema_1.MongooseSchema)({ lowercase });
|
|
26
|
+
}
|
|
27
|
+
exports.Lowercase = Lowercase;
|
|
28
|
+
//# sourceMappingURL=lowercase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lowercase.js","sourceRoot":"","sources":["../../../src/decorators/lowercase.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AAExC;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,SAAS,CAAC,YAAqB,IAAI;IACjD,OAAO,IAAA,uBAAc,EAAC,EAAC,SAAS,EAAQ,CAAC,CAAC;AAC5C,CAAC;AAFD,8BAEC","sourcesContent":["import {MongooseSchema} from \"./schema\";\n\n/**\n * If truthy, Mongoose will add a custom setter that lowercases this string using JavaScript's built-in String#toLowerCase().\n *\n * ### Example\n *\n * ```typescript\n * @Model()\n * export class EventModel {\n * @Lowercase()\n * field: string;\n * }\n * ```\n *\n * @param {boolean} lowercase\n * @returns {Function}\n * @decorator\n * @mongoose\n * @property\n */\nexport function Lowercase(lowercase: boolean = true): PropertyDecorator {\n return MongooseSchema({lowercase} as any);\n}\n"]}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Model = void 0;
|
|
4
|
+
const di_1 = require("@tsed/di");
|
|
5
|
+
const MongooseConnections_1 = require("../services/MongooseConnections");
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
const schemaOptions_1 = require("../utils/schemaOptions");
|
|
8
|
+
/**
|
|
9
|
+
* Define a class as a Mongoose Model. The model can be injected to the Service, Controller, Middleware, Converters or Filter with
|
|
10
|
+
* `@Inject` annotation.
|
|
11
|
+
*
|
|
12
|
+
* ### Example
|
|
13
|
+
*
|
|
14
|
+
* ```typescript
|
|
15
|
+
* @Model()
|
|
16
|
+
* export class EventModel {
|
|
17
|
+
* @Property()
|
|
18
|
+
* field: string;
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* Then inject the model into a service:
|
|
23
|
+
*
|
|
24
|
+
* ```typescript
|
|
25
|
+
* class MyService {
|
|
26
|
+
* constructor(@Inject(EventModel) eventModel: MongooseModel<EventModel>) {
|
|
27
|
+
* eventModel.findById().exec();
|
|
28
|
+
* }
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* ### Options
|
|
33
|
+
*
|
|
34
|
+
* - `schemaOptions` (mongoose.SchemaOptions): Option to configure the schema behavior.
|
|
35
|
+
* - `name` (String): model name.
|
|
36
|
+
* - `collection` (String): collection (optional, induced from model name).
|
|
37
|
+
* - `skipInit` (Boolean): skipInit whether to skip initialization (defaults to false).
|
|
38
|
+
*
|
|
39
|
+
* @param {MongooseModelOptions} options
|
|
40
|
+
* @returns {(target: any) => void}
|
|
41
|
+
* @decorator
|
|
42
|
+
* @mongoose
|
|
43
|
+
* @class
|
|
44
|
+
*/
|
|
45
|
+
function Model(options = {}) {
|
|
46
|
+
return (target) => {
|
|
47
|
+
const { token, collectionName } = (0, utils_1.getModelToken)(target, options);
|
|
48
|
+
(0, di_1.registerProvider)({
|
|
49
|
+
provide: token,
|
|
50
|
+
deps: [],
|
|
51
|
+
useFactory() {
|
|
52
|
+
return (0, utils_1.getSchema)(target, options);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
(0, di_1.registerProvider)({
|
|
56
|
+
provide: target,
|
|
57
|
+
type: "mongoose:model",
|
|
58
|
+
deps: [MongooseConnections_1.MONGOOSE_CONNECTIONS, token],
|
|
59
|
+
useFactory(connections, schema) {
|
|
60
|
+
(0, schemaOptions_1.applySchemaOptions)(schema, (0, schemaOptions_1.schemaOptions)(target));
|
|
61
|
+
return (0, utils_1.createModel)(target, schema, collectionName, options.collection, options.skipInit, connections.get(options.connection), options.discriminatorValue);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
exports.Model = Model;
|
|
67
|
+
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../../src/decorators/model.ts"],"names":[],"mappings":";;;AAAA,iCAA0C;AAG1C,yEAAqE;AACrE,oCAA+D;AAC/D,0DAAyE;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,SAAgB,KAAK,CAAC,UAAgC,EAAE;IACtD,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,MAAM,EAAC,KAAK,EAAE,cAAc,EAAC,GAAG,IAAA,qBAAa,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAE/D,IAAA,qBAAgB,EAAC;YACf,OAAO,EAAE,KAAK;YACd,IAAI,EAAE,EAAE;YACR,UAAU;gBACR,OAAO,IAAA,iBAAS,EAAC,MAAM,EAAE,OAAc,CAAC,CAAC;YAC3C,CAAC;SACF,CAAC,CAAC;QAEH,IAAA,qBAAgB,EAAC;YACf,OAAO,EAAE,MAAM;YACf,IAAI,EAAE,gBAAgB;YACtB,IAAI,EAAE,CAAC,0CAAoB,EAAE,KAAK,CAAC;YACnC,UAAU,CAAC,WAAiC,EAAE,MAAc;gBAC1D,IAAA,kCAAkB,EAAC,MAAM,EAAE,IAAA,6BAAa,EAAC,MAAM,CAAC,CAAC,CAAC;gBAClD,OAAO,IAAA,mBAAW,EAChB,MAAM,EACN,MAAM,EACN,cAAc,EACd,OAAO,CAAC,UAAU,EAClB,OAAO,CAAC,QAAQ,EAChB,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,EACnC,OAAO,CAAC,kBAAkB,CAC3B,CAAC;YACJ,CAAC;SACF,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AA9BD,sBA8BC","sourcesContent":["import {registerProvider} from \"@tsed/di\";\nimport {Schema} from \"mongoose\";\nimport {MongooseModelOptions} from \"../interfaces/MongooseModelOptions\";\nimport {MONGOOSE_CONNECTIONS} from \"../services/MongooseConnections\";\nimport {createModel, getModelToken, getSchema} from \"../utils\";\nimport {applySchemaOptions, schemaOptions} from \"../utils/schemaOptions\";\n\n/**\n * Define a class as a Mongoose Model. The model can be injected to the Service, Controller, Middleware, Converters or Filter with\n * `@Inject` annotation.\n *\n * ### Example\n *\n * ```typescript\n * @Model()\n * export class EventModel {\n * @Property()\n * field: string;\n * }\n * ```\n *\n * Then inject the model into a service:\n *\n * ```typescript\n * class MyService {\n * constructor(@Inject(EventModel) eventModel: MongooseModel<EventModel>) {\n * eventModel.findById().exec();\n * }\n * }\n * ```\n *\n * ### Options\n *\n * - `schemaOptions` (mongoose.SchemaOptions): Option to configure the schema behavior.\n * - `name` (String): model name.\n * - `collection` (String): collection (optional, induced from model name).\n * - `skipInit` (Boolean): skipInit whether to skip initialization (defaults to false).\n *\n * @param {MongooseModelOptions} options\n * @returns {(target: any) => void}\n * @decorator\n * @mongoose\n * @class\n */\nexport function Model(options: MongooseModelOptions = {}) {\n return (target: any) => {\n const {token, collectionName} = getModelToken(target, options);\n\n registerProvider({\n provide: token,\n deps: [],\n useFactory() {\n return getSchema(target, options as any);\n }\n });\n\n registerProvider({\n provide: target,\n type: \"mongoose:model\",\n deps: [MONGOOSE_CONNECTIONS, token],\n useFactory(connections: MONGOOSE_CONNECTIONS, schema: Schema) {\n applySchemaOptions(schema, schemaOptions(target));\n return createModel(\n target,\n schema,\n collectionName,\n options.collection,\n options.skipInit,\n connections.get(options.connection),\n options.discriminatorValue\n );\n }\n });\n };\n}\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MongooseIndex = void 0;
|
|
4
|
+
const schemaOptions_1 = require("../utils/schemaOptions");
|
|
5
|
+
/**
|
|
6
|
+
* Calls schema.index() to define an index (most likely compound) for the schema.
|
|
7
|
+
*
|
|
8
|
+
* ### Example
|
|
9
|
+
*
|
|
10
|
+
* ```typescript
|
|
11
|
+
* @Model()
|
|
12
|
+
* @MongooseIndex({first: 1, second: 1}, {unique: 1})
|
|
13
|
+
* export class EventModel {
|
|
14
|
+
*
|
|
15
|
+
* @Property()
|
|
16
|
+
* first: string;
|
|
17
|
+
*
|
|
18
|
+
* @Property()
|
|
19
|
+
* second: string;
|
|
20
|
+
*
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @param fields
|
|
25
|
+
* @param options
|
|
26
|
+
* @returns {Function}
|
|
27
|
+
* @decorator
|
|
28
|
+
* @mongoose
|
|
29
|
+
* @class
|
|
30
|
+
*/
|
|
31
|
+
function MongooseIndex(fields, options) {
|
|
32
|
+
return (target) => {
|
|
33
|
+
(0, schemaOptions_1.schemaOptions)(target, {
|
|
34
|
+
indexes: [{ fields, options }]
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
exports.MongooseIndex = MongooseIndex;
|
|
39
|
+
//# sourceMappingURL=mongooseIndex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongooseIndex.js","sourceRoot":"","sources":["../../../src/decorators/mongooseIndex.ts"],"names":[],"mappings":";;;AAAA,0DAAqD;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,SAAgB,aAAa,CAAC,MAAc,EAAE,OAAa;IACzD,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,IAAA,6BAAa,EAAC,MAAM,EAAE;YACpB,OAAO,EAAE,CAAC,EAAC,MAAM,EAAE,OAAO,EAAC,CAAC;SAC7B,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAND,sCAMC","sourcesContent":["import {schemaOptions} from \"../utils/schemaOptions\";\n\n/**\n * Calls schema.index() to define an index (most likely compound) for the schema.\n *\n * ### Example\n *\n * ```typescript\n * @Model()\n * @MongooseIndex({first: 1, second: 1}, {unique: 1})\n * export class EventModel {\n *\n * @Property()\n * first: string;\n *\n * @Property()\n * second: string;\n *\n * }\n * ```\n *\n * @param fields\n * @param options\n * @returns {Function}\n * @decorator\n * @mongoose\n * @class\n */\nexport function MongooseIndex(fields: object, options?: any): Function {\n return (target: any) => {\n schemaOptions(target, {\n indexes: [{fields, options}]\n });\n };\n}\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MongooseIndexes = void 0;
|
|
4
|
+
const schemaOptions_1 = require("../utils/schemaOptions");
|
|
5
|
+
/**
|
|
6
|
+
* Calls schema.index() to define multiple indexes (most likely compound) for the schema.
|
|
7
|
+
*
|
|
8
|
+
* ### Example
|
|
9
|
+
*
|
|
10
|
+
* ```typescript
|
|
11
|
+
* @Model()
|
|
12
|
+
* @MongooseIndexes([{fields: {first: 1, second: 1}, options:{unique: 1}}, {fields: {first: 1, third: 1}, options:{unique: 1}}])
|
|
13
|
+
* export class EventModel {
|
|
14
|
+
*
|
|
15
|
+
* @Property()
|
|
16
|
+
* first: string;
|
|
17
|
+
*
|
|
18
|
+
* @Property()
|
|
19
|
+
* second: string;
|
|
20
|
+
*
|
|
21
|
+
* @Property()
|
|
22
|
+
* third: string;
|
|
23
|
+
*
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @param indexes - define multiple mongoose indexes
|
|
28
|
+
* @returns {Function}
|
|
29
|
+
* @decorator
|
|
30
|
+
* @mongoose
|
|
31
|
+
* @class
|
|
32
|
+
*/
|
|
33
|
+
function MongooseIndexes(indexes) {
|
|
34
|
+
return (target) => {
|
|
35
|
+
(0, schemaOptions_1.schemaOptions)(target, { indexes });
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
exports.MongooseIndexes = MongooseIndexes;
|
|
39
|
+
//# sourceMappingURL=mongooseIndexes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongooseIndexes.js","sourceRoot":"","sources":["../../../src/decorators/mongooseIndexes.ts"],"names":[],"mappings":";;;AAAA,0DAAqD;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,SAAgB,eAAe,CAAC,OAA+C;IAC7E,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,IAAA,6BAAa,EAAC,MAAM,EAAE,EAAC,OAAO,EAAC,CAAC,CAAC;IACnC,CAAC,CAAC;AACJ,CAAC;AAJD,0CAIC","sourcesContent":["import {schemaOptions} from \"../utils/schemaOptions\";\n\n/**\n * Calls schema.index() to define multiple indexes (most likely compound) for the schema.\n *\n * ### Example\n *\n * ```typescript\n * @Model()\n * @MongooseIndexes([{fields: {first: 1, second: 1}, options:{unique: 1}}, {fields: {first: 1, third: 1}, options:{unique: 1}}])\n * export class EventModel {\n *\n * @Property()\n * first: string;\n *\n * @Property()\n * second: string;\n *\n * @Property()\n * third: string;\n *\n * }\n * ```\n *\n * @param indexes - define multiple mongoose indexes\n * @returns {Function}\n * @decorator\n * @mongoose\n * @class\n */\nexport function MongooseIndexes(indexes: Array<{fields: object; options?: any}>): Function {\n return (target: any) => {\n schemaOptions(target, {indexes});\n };\n}\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MongoosePlugin = void 0;
|
|
4
|
+
const schemaOptions_1 = require("../utils/schemaOptions");
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param {(schema: "mongoose".Schema, options?: any) => void} plugin
|
|
8
|
+
* @param options
|
|
9
|
+
* @returns {Function}
|
|
10
|
+
* @decorator
|
|
11
|
+
* @mongoose
|
|
12
|
+
* @class
|
|
13
|
+
*/
|
|
14
|
+
function MongoosePlugin(plugin, options) {
|
|
15
|
+
return (target) => {
|
|
16
|
+
(0, schemaOptions_1.schemaOptions)(target, {
|
|
17
|
+
plugins: [{ plugin, options }]
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
exports.MongoosePlugin = MongoosePlugin;
|
|
22
|
+
//# sourceMappingURL=mongoosePlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongoosePlugin.js","sourceRoot":"","sources":["../../../src/decorators/mongoosePlugin.ts"],"names":[],"mappings":";;;AACA,0DAAqD;AAErD;;;;;;;;GAQG;AACH,SAAgB,cAAc,CAAC,MAAwD,EAAE,OAAa;IACpG,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,IAAA,6BAAa,EAAC,MAAM,EAAE;YACpB,OAAO,EAAE,CAAC,EAAC,MAAM,EAAE,OAAO,EAAC,CAAC;SAC7B,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAND,wCAMC","sourcesContent":["import mongoose from \"mongoose\";\nimport {schemaOptions} from \"../utils/schemaOptions\";\n\n/**\n *\n * @param {(schema: \"mongoose\".Schema, options?: any) => void} plugin\n * @param options\n * @returns {Function}\n * @decorator\n * @mongoose\n * @class\n */\nexport function MongoosePlugin(plugin: (schema: mongoose.Schema, options?: any) => void, options?: any): Function {\n return (target: any) => {\n schemaOptions(target, {\n plugins: [{plugin, options}]\n });\n };\n}\n"]}
|