@tsed/mongoose 7.13.3 → 7.13.4
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.
|
@@ -48,7 +48,7 @@ const schemaOptions_1 = require("../utils/schemaOptions");
|
|
|
48
48
|
function Model(options = {}) {
|
|
49
49
|
return (0, core_1.useDecorators)((target) => {
|
|
50
50
|
const { token, collectionName } = (0, createModel_1.getModelToken)(target, options);
|
|
51
|
-
(0, schema_1.DiscriminatorValue)(options.discriminatorValue
|
|
51
|
+
options.discriminatorValue && (0, schema_1.DiscriminatorValue)(options.discriminatorValue)(target);
|
|
52
52
|
(0, di_1.registerProvider)({
|
|
53
53
|
provide: token,
|
|
54
54
|
deps: [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../../src/decorators/model.ts"],"names":[],"mappings":";;;AAAA,qCAAiD;AACjD,iCAA0C;AAC1C,yCAAgD;AAGhD,yEAAqE;AACrE,sDAAgE;AAChE,wDAAgD;AAChD,0DAAyE;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,SAAgB,KAAK,CAAC,UAAgC,EAAE;IACtD,OAAO,IAAA,oBAAa,EAAC,CAAC,MAAW,EAAE,EAAE;QACnC,MAAM,EAAC,KAAK,EAAE,cAAc,EAAC,GAAG,IAAA,2BAAa,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../../src/decorators/model.ts"],"names":[],"mappings":";;;AAAA,qCAAiD;AACjD,iCAA0C;AAC1C,yCAAgD;AAGhD,yEAAqE;AACrE,sDAAgE;AAChE,wDAAgD;AAChD,0DAAyE;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,SAAgB,KAAK,CAAC,UAAgC,EAAE;IACtD,OAAO,IAAA,oBAAa,EAAC,CAAC,MAAW,EAAE,EAAE;QACnC,MAAM,EAAC,KAAK,EAAE,cAAc,EAAC,GAAG,IAAA,2BAAa,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAE/D,OAAO,CAAC,kBAAkB,IAAI,IAAA,2BAAkB,EAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;QAErF,IAAA,qBAAgB,EAAC;YACf,OAAO,EAAE,KAAK;YACd,IAAI,EAAE,EAAE;YACR,UAAU;gBACR,OAAO,IAAA,wBAAS,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,yBAAW,EAChB,MAAM,EACN,MAAM,EACN,cAAc,EACd,OAAO,CAAC,UAAU,EAClB,OAAO,CAAC,eAAe,EACvB,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,CACpC,CAAC;YACJ,CAAC;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AA/BD,sBA+BC","sourcesContent":["import {nameOf, useDecorators} from \"@tsed/core\";\nimport {registerProvider} from \"@tsed/di\";\nimport {DiscriminatorValue} from \"@tsed/schema\";\nimport {Schema} from \"mongoose\";\nimport {MongooseModelOptions} from \"../interfaces/MongooseModelOptions\";\nimport {MONGOOSE_CONNECTIONS} from \"../services/MongooseConnections\";\nimport {createModel, getModelToken} from \"../utils/createModel\";\nimport {getSchema} from \"../utils/createSchema\";\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 useDecorators((target: any) => {\n const {token, collectionName} = getModelToken(target, options);\n\n options.discriminatorValue && DiscriminatorValue(options.discriminatorValue)(target);\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.overwriteModels,\n connections.get(options.connection)\n );\n }\n });\n });\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useDecorators } from "@tsed/core";
|
|
2
2
|
import { registerProvider } from "@tsed/di";
|
|
3
3
|
import { DiscriminatorValue } from "@tsed/schema";
|
|
4
4
|
import { MONGOOSE_CONNECTIONS } from "../services/MongooseConnections.js";
|
|
@@ -45,7 +45,7 @@ import { applySchemaOptions, schemaOptions } from "../utils/schemaOptions.js";
|
|
|
45
45
|
export function Model(options = {}) {
|
|
46
46
|
return useDecorators((target) => {
|
|
47
47
|
const { token, collectionName } = getModelToken(target, options);
|
|
48
|
-
|
|
48
|
+
options.discriminatorValue && DiscriminatorValue(options.discriminatorValue)(target);
|
|
49
49
|
registerProvider({
|
|
50
50
|
provide: token,
|
|
51
51
|
deps: [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../../src/decorators/model.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../../src/decorators/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,aAAa,EAAC,MAAM,YAAY,CAAC;AACjD,OAAO,EAAC,gBAAgB,EAAC,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAC,kBAAkB,EAAC,MAAM,cAAc,CAAC;AAGhD,OAAO,EAAC,oBAAoB,EAAC,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAC,WAAW,EAAE,aAAa,EAAC,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAC,SAAS,EAAC,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAC,kBAAkB,EAAE,aAAa,EAAC,MAAM,wBAAwB,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,UAAU,KAAK,CAAC,UAAgC,EAAE;IACtD,OAAO,aAAa,CAAC,CAAC,MAAW,EAAE,EAAE;QACnC,MAAM,EAAC,KAAK,EAAE,cAAc,EAAC,GAAG,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAE/D,OAAO,CAAC,kBAAkB,IAAI,kBAAkB,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;QAErF,gBAAgB,CAAC;YACf,OAAO,EAAE,KAAK;YACd,IAAI,EAAE,EAAE;YACR,UAAU;gBACR,OAAO,SAAS,CAAC,MAAM,EAAE,OAAc,CAAC,CAAC;YAC3C,CAAC;SACF,CAAC,CAAC;QAEH,gBAAgB,CAAC;YACf,OAAO,EAAE,MAAM;YACf,IAAI,EAAE,gBAAgB;YACtB,IAAI,EAAE,CAAC,oBAAoB,EAAE,KAAK,CAAC;YACnC,UAAU,CAAC,WAAiC,EAAE,MAAc;gBAC1D,kBAAkB,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;gBAClD,OAAO,WAAW,CAChB,MAAM,EACN,MAAM,EACN,cAAc,EACd,OAAO,CAAC,UAAU,EAClB,OAAO,CAAC,eAAe,EACvB,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,CACpC,CAAC;YACJ,CAAC;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {nameOf, useDecorators} from \"@tsed/core\";\nimport {registerProvider} from \"@tsed/di\";\nimport {DiscriminatorValue} from \"@tsed/schema\";\nimport {Schema} from \"mongoose\";\nimport {MongooseModelOptions} from \"../interfaces/MongooseModelOptions\";\nimport {MONGOOSE_CONNECTIONS} from \"../services/MongooseConnections\";\nimport {createModel, getModelToken} from \"../utils/createModel\";\nimport {getSchema} from \"../utils/createSchema\";\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 useDecorators((target: any) => {\n const {token, collectionName} = getModelToken(target, options);\n\n options.discriminatorValue && DiscriminatorValue(options.discriminatorValue)(target);\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.overwriteModels,\n connections.get(options.connection)\n );\n }\n });\n });\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/mongoose",
|
|
3
|
-
"version": "7.13.
|
|
3
|
+
"version": "7.13.4",
|
|
4
4
|
"description": "Mongoose package for Ts.ED framework",
|
|
5
5
|
"private": false,
|
|
6
6
|
"keywords": [
|
|
@@ -32,21 +32,21 @@
|
|
|
32
32
|
"tslib": "2.4.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@tsed/ajv": "7.13.
|
|
36
|
-
"@tsed/core": "7.13.
|
|
37
|
-
"@tsed/di": "7.13.
|
|
38
|
-
"@tsed/json-mapper": "7.13.
|
|
35
|
+
"@tsed/ajv": "7.13.4",
|
|
36
|
+
"@tsed/core": "7.13.4",
|
|
37
|
+
"@tsed/di": "7.13.4",
|
|
38
|
+
"@tsed/json-mapper": "7.13.4",
|
|
39
39
|
"@tsed/logger": ">=6.2.2",
|
|
40
|
-
"@tsed/schema": "7.13.
|
|
40
|
+
"@tsed/schema": "7.13.4",
|
|
41
41
|
"mongoose": "6.5.1"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@tsed/ajv": "^7.13.
|
|
45
|
-
"@tsed/core": "^7.13.
|
|
46
|
-
"@tsed/di": "^7.13.
|
|
47
|
-
"@tsed/json-mapper": "^7.13.
|
|
44
|
+
"@tsed/ajv": "^7.13.4",
|
|
45
|
+
"@tsed/core": "^7.13.4",
|
|
46
|
+
"@tsed/di": "^7.13.4",
|
|
47
|
+
"@tsed/json-mapper": "^7.13.4",
|
|
48
48
|
"@tsed/logger": ">=6.2.2",
|
|
49
|
-
"@tsed/schema": "^7.13.
|
|
49
|
+
"@tsed/schema": "^7.13.4",
|
|
50
50
|
"mongoose": ">=6.0.0"
|
|
51
51
|
},
|
|
52
52
|
"repository": "https://github.com/tsedio/tsed",
|