@midwayjs/typegoose 3.0.3 → 3.0.6
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/typegoose",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.6",
|
|
4
4
|
"description": "Midway Component for typegoose",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -14,22 +14,21 @@
|
|
|
14
14
|
"author": "",
|
|
15
15
|
"files": [
|
|
16
16
|
"dist/**/*.js",
|
|
17
|
-
"dist/**/*.d.ts"
|
|
18
|
-
"dist/**/*.js.map"
|
|
17
|
+
"dist/**/*.d.ts"
|
|
19
18
|
],
|
|
20
19
|
"engines": {
|
|
21
20
|
"node": ">=12"
|
|
22
21
|
},
|
|
23
22
|
"license": "MIT",
|
|
24
23
|
"dependencies": {
|
|
25
|
-
"@midwayjs/mongoose": "^3.0.
|
|
24
|
+
"@midwayjs/mongoose": "^3.0.6"
|
|
26
25
|
},
|
|
27
26
|
"devDependencies": {
|
|
28
|
-
"@midwayjs/core": "^3.0.
|
|
29
|
-
"@midwayjs/decorator": "^3.0.
|
|
30
|
-
"@midwayjs/mock": "^3.0.
|
|
31
|
-
"@typegoose/typegoose": "9.
|
|
32
|
-
"mongoose": "6.1
|
|
27
|
+
"@midwayjs/core": "^3.0.6",
|
|
28
|
+
"@midwayjs/decorator": "^3.0.6",
|
|
29
|
+
"@midwayjs/mock": "^3.0.6",
|
|
30
|
+
"@typegoose/typegoose": "9.6.2",
|
|
31
|
+
"mongoose": "6.2.1"
|
|
33
32
|
},
|
|
34
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "afaa5b59a2be85e915233a9268c0e05965dd5c61"
|
|
35
34
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.js","sour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C,mBAAmB,QAAQ,CAAC,cAAc,YAAY,CAAC,CAAC;aACzE;SACF;QAED,QAAQ;QACR,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,EAAE;YACxD,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;YACvB,MAAM,KAAK,CAAC,OAAO,CACjB,IAAI,CAAC,iBAAiB,CAAC,GAAG,EAC1B,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAC/B,CAAC;SACH;IACH,CAAC;IAED,KAAK,CAAC,MAAM;QACV,IAAI,IAAI,CAAC,UAAU,EAAE;YACnB,MAAM,KAAK,CAAC,UAAU,EAAE,CAAC;SAC1B;IACH,CAAC;CACF,CAAA;AA5DC;IADC,IAAA,kBAAM,EAAC,UAAU,CAAC;;iEACD;AAKlB;IADC,IAAA,eAAG,GAAE;;mDACkB;AAGxB;IADC,IAAA,kBAAM,GAAE;8BACS,6BAAsB;gEAAC;AAKzC;IADC,IAAA,gBAAI,GAAE;;;;kDAcN;AA5BU,sBAAsB;IAJlC,IAAA,yBAAa,EAAC;QACb,SAAS,EAAE,WAAW;QACtB,OAAO,EAAE,CAAC,QAAQ,CAAC;KACpB,CAAC;GACW,sBAAsB,CA8DlC;AA9DY,wDAAsB","sourcesContent":["import {\n Config,\n Configuration,\n getClassMetadata,\n Init,\n Inject,\n listModule,\n App,\n} from '@midwayjs/decorator';\nimport * as mongoose from '@midwayjs/mongoose';\nimport { ENTITY_MODEL_KEY } from './interface';\nimport { getModelForClass } from '@typegoose/typegoose';\nimport * as mongo from 'mongoose';\nimport { IMidwayApplication, MidwayDecoratorService } from '@midwayjs/core';\n\n@Configuration({\n namespace: 'typegoose',\n imports: [mongoose],\n})\nexport class TypegooseConfiguration {\n @Config('mongoose')\n oldMongooseConfig;\n\n legacyMode = false;\n\n @App()\n app: IMidwayApplication;\n\n @Inject()\n decoratorService: MidwayDecoratorService;\n\n modelMap = new WeakMap();\n\n @Init()\n async init() {\n this.decoratorService.registerPropertyHandler(\n ENTITY_MODEL_KEY,\n (\n propertyName,\n meta: {\n modelKey: any;\n connectionName: string;\n }\n ) => {\n return this.modelMap.get(meta.modelKey);\n }\n );\n }\n\n async onReady(container) {\n const connectionFactory = await container.getAsync(\n mongoose.MongooseConnectionServiceFactory\n );\n const Models = listModule(ENTITY_MODEL_KEY);\n for (const Model of Models) {\n const metadata = getClassMetadata(ENTITY_MODEL_KEY, Model) ?? {};\n const connectionName = metadata.connectionName ?? 'default';\n const conn = connectionFactory.get(connectionName);\n if (conn) {\n const model = getModelForClass(Model, { existingConnection: conn });\n this.modelMap.set(Model, model);\n } else {\n throw new Error(`connection name ${metadata.connectionName} not found`);\n }\n }\n\n // 兼容老代码\n if (Models.length === 0 && this.oldMongooseConfig['uri']) {\n this.legacyMode = true;\n await mongo.connect(\n this.oldMongooseConfig.uri,\n this.oldMongooseConfig.options\n );\n }\n }\n\n async onStop() {\n if (this.legacyMode) {\n await mongo.disconnect();\n }\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"entityModel.js","sourceRoot":"","sources":["../../src/decorator/entityModel.ts"],"names":[],"mappings":";;;AAAA,mDAAoE;AACpE,4CAA+D;AAE/D,SAAgB,WAAW,CAAC,OAAuB;IACjD,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,IAAA,sBAAU,EAAC,4BAAgB,EAAE,MAAM,CAAC,CAAC;QACrC,IAAA,6BAAiB,EAAC,4BAAgB,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACvD,CAAC,CAAC;AACJ,CAAC;AALD,kCAKC","sourcesContent":["import { saveClassMetadata, saveModule } from '@midwayjs/decorator';\nimport { ENTITY_MODEL_KEY, EntityOptions } from '../interface';\n\nexport function EntityModel(options?: EntityOptions): ClassDecorator {\n return (target: any) => {\n saveModule(ENTITY_MODEL_KEY, target);\n saveClassMetadata(ENTITY_MODEL_KEY, options, target);\n };\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"injectEntityModel.js","sourceRoot":"","sources":["../../src/decorator/injectEntityModel.ts"],"names":[],"mappings":";;;AAAA,mDAAoE;AACpE,4CAAgD;AAEhD,SAAgB,iBAAiB,CAAC,QAAa;IAC7C,OAAO,IAAA,yCAA6B,EAAC,4BAAgB,EAAE;QACrD,QAAQ;KACT,CAAC,CAAC;AACL,CAAC;AAJD,8CAIC","sourcesContent":["import { createCustomPropertyDecorator } from '@midwayjs/decorator';\nimport { ENTITY_MODEL_KEY } from '../interface';\n\nexport function InjectEntityModel(modelKey: any) {\n return createCustomPropertyDecorator(ENTITY_MODEL_KEY, {\n modelKey,\n });\n}\n"]}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,iDAA0E;AAAjE,8GAAA,sBAAsB,OAAiB;AAChD,0DAAwC;AACxC,gEAA8C","sourcesContent":["export { TypegooseConfiguration as Configuration } from './configuration';\nexport * from './decorator/entityModel';\nexport * from './decorator/injectEntityModel';\n"]}
|
package/dist/interface.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../src/interface.ts"],"names":[],"mappings":";;;AAIa,QAAA,gBAAgB,GAAI,iBAAiB,CAAC","sourcesContent":["export interface EntityOptions {\n connectionName: string;\n}\n\nexport const ENTITY_MODEL_KEY = 'TYPEGOOSE:MODEL';\n"]}
|