@tsed/mongoose 8.0.0-alpha.1 → 8.0.0-alpha.11
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 +0 -2
- 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 +25 -0
- package/lib/types/decorators/mongoosePlugin.d.ts +25 -0
- package/lib/types/decorators/numberDecimal.d.ts +25 -0
- package/lib/types/decorators/objectID.d.ts +25 -0
- package/lib/types/decorators/schema.d.ts +25 -0
- package/lib/types/interfaces/MongooseConnectionOptions.d.ts +25 -0
- package/lib/types/interfaces/MongooseDocument.d.ts +25 -0
- package/lib/types/interfaces/MongooseModel.d.ts +25 -0
- package/lib/types/interfaces/MongooseModelOptions.d.ts +0 -4
- package/lib/types/interfaces/MongooseSchemaOptions.d.ts +25 -0
- package/lib/types/services/MongooseService.d.ts +25 -0
- package/lib/types/utils/createModel.d.ts +25 -0
- package/lib/types/utils/createSchema.d.ts +25 -0
- package/lib/types/utils/schemaOptions.d.ts +25 -0
- package/package.json +24 -24
- package/vitest.config.mts +5 -5
- 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 -71
- 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 -11
- 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
- package/vitest.setup.mts +0 -10
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
/// <reference types="mongoose/types/aggregate.js" />
|
|
2
|
+
/// <reference types="mongoose/types/callback.js" />
|
|
3
|
+
/// <reference types="mongoose/types/collection.js" />
|
|
4
|
+
/// <reference types="mongoose/types/connection.js" />
|
|
5
|
+
/// <reference types="mongoose/types/cursor.js" />
|
|
6
|
+
/// <reference types="mongoose/types/document.js" />
|
|
7
|
+
/// <reference types="mongoose/types/error.js" />
|
|
8
|
+
/// <reference types="mongoose/types/expressions.js" />
|
|
9
|
+
/// <reference types="mongoose/types/helpers.js" />
|
|
10
|
+
/// <reference types="mongoose/types/middlewares.js" />
|
|
11
|
+
/// <reference types="mongoose/types/indexes.js" />
|
|
12
|
+
/// <reference types="mongoose/types/models.js" />
|
|
13
|
+
/// <reference types="mongoose/types/mongooseoptions.js" />
|
|
14
|
+
/// <reference types="mongoose/types/pipelinestage.js" />
|
|
15
|
+
/// <reference types="mongoose/types/populate.js" />
|
|
16
|
+
/// <reference types="mongoose/types/query.js" />
|
|
17
|
+
/// <reference types="mongoose/types/schemaoptions.js" />
|
|
18
|
+
/// <reference types="mongoose/types/schematypes.js" />
|
|
19
|
+
/// <reference types="mongoose/types/session.js" />
|
|
20
|
+
/// <reference types="mongoose/types/types.js" />
|
|
21
|
+
/// <reference types="mongoose/types/utility.js" />
|
|
22
|
+
/// <reference types="mongoose/types/validation.js" />
|
|
23
|
+
/// <reference types="mongoose/types/virtuals.js" />
|
|
24
|
+
/// <reference types="mongoose/types/inferschematype.js" />
|
|
25
|
+
/// <reference types="mongoose/types/inferrawdoctype.js" />
|
|
1
26
|
import { Type } from "@tsed/core";
|
|
2
27
|
import mongoose, { Connection } from "mongoose";
|
|
3
28
|
export declare function getModelToken(target: Type<any>, options: any): {
|
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
/// <reference types="mongoose/types/aggregate.js" />
|
|
2
|
+
/// <reference types="mongoose/types/callback.js" />
|
|
3
|
+
/// <reference types="mongoose/types/collection.js" />
|
|
4
|
+
/// <reference types="mongoose/types/connection.js" />
|
|
5
|
+
/// <reference types="mongoose/types/cursor.js" />
|
|
6
|
+
/// <reference types="mongoose/types/document.js" />
|
|
7
|
+
/// <reference types="mongoose/types/error.js" />
|
|
8
|
+
/// <reference types="mongoose/types/expressions.js" />
|
|
9
|
+
/// <reference types="mongoose/types/helpers.js" />
|
|
10
|
+
/// <reference types="mongoose/types/middlewares.js" />
|
|
11
|
+
/// <reference types="mongoose/types/indexes.js" />
|
|
12
|
+
/// <reference types="mongoose/types/models.js" />
|
|
13
|
+
/// <reference types="mongoose/types/mongooseoptions.js" />
|
|
14
|
+
/// <reference types="mongoose/types/pipelinestage.js" />
|
|
15
|
+
/// <reference types="mongoose/types/populate.js" />
|
|
16
|
+
/// <reference types="mongoose/types/query.js" />
|
|
17
|
+
/// <reference types="mongoose/types/schemaoptions.js" />
|
|
18
|
+
/// <reference types="mongoose/types/schematypes.js" />
|
|
19
|
+
/// <reference types="mongoose/types/session.js" />
|
|
20
|
+
/// <reference types="mongoose/types/types.js" />
|
|
21
|
+
/// <reference types="mongoose/types/utility.js" />
|
|
22
|
+
/// <reference types="mongoose/types/validation.js" />
|
|
23
|
+
/// <reference types="mongoose/types/virtuals.js" />
|
|
24
|
+
/// <reference types="mongoose/types/inferschematype.js" />
|
|
25
|
+
/// <reference types="mongoose/types/inferrawdoctype.js" />
|
|
1
26
|
import { Type } from "@tsed/core";
|
|
2
27
|
import { JsonEntityStore } from "@tsed/schema";
|
|
3
28
|
import mongoose, { Schema, SchemaDefinition, SchemaTypeOptions } from "mongoose";
|
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
/// <reference types="mongoose/types/aggregate.js" />
|
|
2
|
+
/// <reference types="mongoose/types/callback.js" />
|
|
3
|
+
/// <reference types="mongoose/types/collection.js" />
|
|
4
|
+
/// <reference types="mongoose/types/connection.js" />
|
|
5
|
+
/// <reference types="mongoose/types/cursor.js" />
|
|
6
|
+
/// <reference types="mongoose/types/document.js" />
|
|
7
|
+
/// <reference types="mongoose/types/error.js" />
|
|
8
|
+
/// <reference types="mongoose/types/expressions.js" />
|
|
9
|
+
/// <reference types="mongoose/types/helpers.js" />
|
|
10
|
+
/// <reference types="mongoose/types/middlewares.js" />
|
|
11
|
+
/// <reference types="mongoose/types/indexes.js" />
|
|
12
|
+
/// <reference types="mongoose/types/models.js" />
|
|
13
|
+
/// <reference types="mongoose/types/mongooseoptions.js" />
|
|
14
|
+
/// <reference types="mongoose/types/pipelinestage.js" />
|
|
15
|
+
/// <reference types="mongoose/types/populate.js" />
|
|
16
|
+
/// <reference types="mongoose/types/query.js" />
|
|
17
|
+
/// <reference types="mongoose/types/schemaoptions.js" />
|
|
18
|
+
/// <reference types="mongoose/types/schematypes.js" />
|
|
19
|
+
/// <reference types="mongoose/types/session.js" />
|
|
20
|
+
/// <reference types="mongoose/types/types.js" />
|
|
21
|
+
/// <reference types="mongoose/types/utility.js" />
|
|
22
|
+
/// <reference types="mongoose/types/validation.js" />
|
|
23
|
+
/// <reference types="mongoose/types/virtuals.js" />
|
|
24
|
+
/// <reference types="mongoose/types/inferschematype.js" />
|
|
25
|
+
/// <reference types="mongoose/types/inferrawdoctype.js" />
|
|
1
26
|
import { Schema } from "mongoose";
|
|
2
27
|
import { MongooseNextCB, MongoosePreHookCB, MongooseSchemaOptions } from "../interfaces/MongooseSchemaOptions.js";
|
|
3
28
|
/**
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/mongoose",
|
|
3
3
|
"description": "Mongoose package for Ts.ED framework",
|
|
4
|
-
"type": "
|
|
5
|
-
"version": "8.0.0-alpha.
|
|
4
|
+
"type": "module",
|
|
5
|
+
"version": "8.0.0-alpha.11",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"tsed",
|
|
8
8
|
"mongoose",
|
|
@@ -11,15 +11,14 @@
|
|
|
11
11
|
"orm"
|
|
12
12
|
],
|
|
13
13
|
"source": "./src/index.ts",
|
|
14
|
-
"main": "./lib/
|
|
14
|
+
"main": "./lib/esm/index.js",
|
|
15
15
|
"module": "./lib/esm/index.js",
|
|
16
16
|
"typings": "./lib/types/index.d.ts",
|
|
17
17
|
"exports": {
|
|
18
18
|
".": {
|
|
19
19
|
"types": "./lib/types/index.d.ts",
|
|
20
20
|
"import": "./lib/esm/index.js",
|
|
21
|
-
"
|
|
22
|
-
"default": "./lib/cjs/index.js"
|
|
21
|
+
"default": "./lib/esm/index.js"
|
|
23
22
|
}
|
|
24
23
|
},
|
|
25
24
|
"scripts": {
|
|
@@ -30,30 +29,31 @@
|
|
|
30
29
|
"test:ci": "vitest run --coverage.thresholds.autoUpdate=true"
|
|
31
30
|
},
|
|
32
31
|
"dependencies": {
|
|
33
|
-
"change-case": "4.
|
|
34
|
-
"tslib": "2.
|
|
32
|
+
"change-case": "5.4.4",
|
|
33
|
+
"tslib": "2.7.0"
|
|
35
34
|
},
|
|
36
35
|
"devDependencies": {
|
|
37
|
-
"@tsed/ajv": "8.0.0-alpha.
|
|
38
|
-
"@tsed/barrels": "8.0.0-alpha.
|
|
39
|
-
"@tsed/core": "8.0.0-alpha.
|
|
40
|
-
"@tsed/di": "8.0.0-alpha.
|
|
41
|
-
"@tsed/json-mapper": "8.0.0-alpha.
|
|
42
|
-
"@tsed/logger": "
|
|
43
|
-
"@tsed/schema": "8.0.0-alpha.
|
|
44
|
-
"@tsed/
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
36
|
+
"@tsed/ajv": "8.0.0-alpha.11",
|
|
37
|
+
"@tsed/barrels": "8.0.0-alpha.11",
|
|
38
|
+
"@tsed/core": "8.0.0-alpha.11",
|
|
39
|
+
"@tsed/di": "8.0.0-alpha.11",
|
|
40
|
+
"@tsed/json-mapper": "8.0.0-alpha.11",
|
|
41
|
+
"@tsed/logger": "^6.7.8",
|
|
42
|
+
"@tsed/schema": "8.0.0-alpha.11",
|
|
43
|
+
"@tsed/testcontainers-mongo": "8.0.0-alpha.11",
|
|
44
|
+
"@tsed/typescript": "8.0.0-alpha.11",
|
|
45
|
+
"eslint": "9.12.0",
|
|
46
|
+
"mongoose": "8.7.0",
|
|
47
|
+
"typescript": "5.4.5",
|
|
48
|
+
"vitest": "2.1.2"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@tsed/ajv": "8.0.0-alpha.
|
|
52
|
-
"@tsed/core": "8.0.0-alpha.
|
|
53
|
-
"@tsed/di": "8.0.0-alpha.
|
|
54
|
-
"@tsed/json-mapper": "8.0.0-alpha.
|
|
51
|
+
"@tsed/ajv": "8.0.0-alpha.11",
|
|
52
|
+
"@tsed/core": "8.0.0-alpha.11",
|
|
53
|
+
"@tsed/di": "8.0.0-alpha.11",
|
|
54
|
+
"@tsed/json-mapper": "8.0.0-alpha.11",
|
|
55
55
|
"@tsed/logger": ">=6.7.5",
|
|
56
|
-
"@tsed/schema": "8.0.0-alpha.
|
|
56
|
+
"@tsed/schema": "8.0.0-alpha.11",
|
|
57
57
|
"mongoose": ">=6.0.0"
|
|
58
58
|
},
|
|
59
59
|
"repository": "https://github.com/tsedio/tsed",
|
package/vitest.config.mts
CHANGED
|
@@ -12,12 +12,12 @@ export default defineConfig(
|
|
|
12
12
|
coverage: {
|
|
13
13
|
...presets.test.coverage,
|
|
14
14
|
thresholds: {
|
|
15
|
-
statements:
|
|
16
|
-
branches:
|
|
17
|
-
functions:
|
|
18
|
-
lines:
|
|
15
|
+
statements: 0,
|
|
16
|
+
branches: 0,
|
|
17
|
+
functions: 0,
|
|
18
|
+
lines: 0
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
);
|
|
23
|
+
);
|
|
@@ -1,36 +0,0 @@
|
|
|
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_js_1 = require("./services/MongooseConnections.js");
|
|
8
|
-
const MongooseService_js_1 = require("./services/MongooseService.js");
|
|
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?.mongoose) {
|
|
20
|
-
cache.connection = this.mongooseService.get();
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
$onInit() { }
|
|
24
|
-
$onDestroy() {
|
|
25
|
-
return this.mongooseService.closeConnections();
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
MongooseModule = tslib_1.__decorate([
|
|
29
|
-
(0, di_2.Module)({
|
|
30
|
-
imports: [MongooseConnections_js_1.MONGOOSE_CONNECTIONS]
|
|
31
|
-
}),
|
|
32
|
-
tslib_1.__param(1, (0, di_1.Configuration)()),
|
|
33
|
-
tslib_1.__metadata("design:paramtypes", [MongooseService_js_1.MongooseService, Object])
|
|
34
|
-
], MongooseModule);
|
|
35
|
-
exports.MongooseModule = MongooseModule;
|
|
36
|
-
//# sourceMappingURL=MongooseModule.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MongooseModule.js","sourceRoot":"","sources":["../../src/MongooseModule.ts"],"names":[],"mappings":";;;;AAAA,iCAA+C;AAC/C,iCAA2C;AAC3C,8EAAuE;AACvE,sEAA8D;AAE9D;;GAEG;AAII,IAAM,cAAc,GAApB,MAAM,cAAc;IACzB,YACU,eAAgC,EACf,QAAuB;QADxC,oBAAe,GAAf,eAAe,CAAiB;QACf,aAAQ,GAAR,QAAQ,CAAe;QAEhD,6EAA6E;QAC7E,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAM,OAAO,CAAC,CAAC;QAE9C,uBAAuB;QACvB,IAAI,KAAK,EAAE,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;AAnBY,cAAc;IAH1B,IAAA,WAAM,EAAC;QACN,OAAO,EAAE,CAAC,6CAAoB,CAAC;KAChC,CAAC;IAIG,mBAAA,IAAA,kBAAa,GAAE,CAAA;6CADS,oCAAe;GAF/B,cAAc,CAmB1B;AAnBY,wCAAc"}
|
|
@@ -1,24 +0,0 @@
|
|
|
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=constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/constants/constants.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"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Auto = void 0;
|
|
4
|
-
const schema_js_1 = require("./schema.js");
|
|
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_js_1.MongooseSchema)({ auto });
|
|
26
|
-
}
|
|
27
|
-
exports.Auto = Auto;
|
|
28
|
-
//# sourceMappingURL=auto.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auto.js","sourceRoot":"","sources":["../../../src/decorators/auto.ts"],"names":[],"mappings":";;;AAAA,2CAA2C;AAE3C;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,IAAI,CAAC,OAAgB,IAAI;IACvC,OAAO,IAAA,0BAAc,EAAC,EAAC,IAAI,EAAQ,CAAC,CAAC;AACvC,CAAC;AAFD,oBAEC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DiscriminatorKey = void 0;
|
|
4
|
-
var schema_1 = require("@tsed/schema");
|
|
5
|
-
Object.defineProperty(exports, "DiscriminatorKey", { enumerable: true, get: function () { return schema_1.DiscriminatorKey; } });
|
|
6
|
-
//# sourceMappingURL=discriminatorKey.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"discriminatorKey.js","sourceRoot":"","sources":["../../../src/decorators/discriminatorKey.ts"],"names":[],"mappings":";;;AAAA,uCAA8C;AAAtC,0GAAA,gBAAgB,OAAA"}
|
|
@@ -1,65 +0,0 @@
|
|
|
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_js_1 = require("../constants/constants.js");
|
|
8
|
-
const json_mapper_1 = require("@tsed/json-mapper");
|
|
9
|
-
const MongooseModels_js_1 = require("../registries/MongooseModels.js");
|
|
10
|
-
function isRef(value) {
|
|
11
|
-
return (value && value._bsontype) || (0, core_1.isString)(value);
|
|
12
|
-
}
|
|
13
|
-
function getType(refPath, ctx) {
|
|
14
|
-
return (ctx?.self[refPath] && MongooseModels_js_1.MongooseModels.get(ctx.self[refPath])) || Object;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Define a property as mongoose reference to other Model (decorated with @Model).
|
|
18
|
-
*
|
|
19
|
-
* ### Example
|
|
20
|
-
*
|
|
21
|
-
* ```typescript
|
|
22
|
-
* @Model()
|
|
23
|
-
* class FooModel {
|
|
24
|
-
*
|
|
25
|
-
* @DynamicRef('type')
|
|
26
|
-
* field: DynamicRef<OtherFooModel | OtherModel>
|
|
27
|
-
*
|
|
28
|
-
* @Enum(['OtherFooModel', 'OtherModel'])
|
|
29
|
-
* type: string
|
|
30
|
-
* }
|
|
31
|
-
*
|
|
32
|
-
* @Model()
|
|
33
|
-
* class OtherFooModel {
|
|
34
|
-
* }
|
|
35
|
-
*
|
|
36
|
-
* @Model()
|
|
37
|
-
* class OtherModel {
|
|
38
|
-
* }
|
|
39
|
-
* ```
|
|
40
|
-
*
|
|
41
|
-
* @param refPath {String} the path to apply the correct model
|
|
42
|
-
* @param types {Type} the classes to generate the correct json schema
|
|
43
|
-
* @returns {Function}
|
|
44
|
-
* @decorator
|
|
45
|
-
* @mongoose
|
|
46
|
-
* @property
|
|
47
|
-
*/
|
|
48
|
-
function DynamicRef(refPath, ...types) {
|
|
49
|
-
return (0, core_1.useDecorators)((0, schema_1.Property)(Object), (0, schema_1.Example)("5ce7ad3028890bd71749d477"), (0, schema_1.Description)("A reference ObjectID"), (0, core_1.StoreMerge)(constants_js_1.MONGOOSE_SCHEMA, {
|
|
50
|
-
type: mongoose_1.Schema.Types.ObjectId,
|
|
51
|
-
refPath
|
|
52
|
-
}), (0, json_mapper_1.OnDeserialize)((value, ctx) => {
|
|
53
|
-
if (isRef(value)) {
|
|
54
|
-
return value.toString();
|
|
55
|
-
}
|
|
56
|
-
return (0, json_mapper_1.deserialize)(value, { ...ctx, type: getType(refPath, ctx) });
|
|
57
|
-
}), (0, json_mapper_1.OnSerialize)((value, ctx) => {
|
|
58
|
-
if (isRef(value)) {
|
|
59
|
-
return value.toString();
|
|
60
|
-
}
|
|
61
|
-
return (0, json_mapper_1.serialize)(value, { ...ctx, type: getType(refPath, ctx) });
|
|
62
|
-
}), (0, schema_1.OneOf)((0, schema_1.string)().example("5ce7ad3028890bd71749d477").description("A reference ObjectID"), ...types));
|
|
63
|
-
}
|
|
64
|
-
exports.DynamicRef = DynamicRef;
|
|
65
|
-
//# sourceMappingURL=dynamicRef.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dynamicRef.js","sourceRoot":"","sources":["../../../src/decorators/dynamicRef.ts"],"names":[],"mappings":";;;AAAA,qCAAyF;AACzF,yCAA4F;AAC5F,uCAAkD;AAClD,4DAA0D;AAC1D,mDAAqF;AACrF,uEAA+D;AAE/D,SAAS,KAAK,CAAC,KAA+B;IAC5C,OAAO,CAAC,KAAK,IAAI,KAAK,CAAC,SAAS,CAAC,IAAI,IAAA,eAAQ,EAAC,KAAK,CAAC,CAAC;AACvD,CAAC;AAED,SAAS,OAAO,CAAC,OAAe,EAAE,GAAoB;IACpD,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,kCAAc,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAW,CAAC,CAAC,IAAI,MAAM,CAAC;AAC3F,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,SAAgB,UAAU,CAAC,OAAe,EAAE,GAAG,KAAkB;IAC/D,OAAO,IAAA,oBAAa,EAClB,IAAA,iBAAQ,EAAC,MAAM,CAAC,EAChB,IAAA,gBAAO,EAAC,0BAA0B,CAAC,EACnC,IAAA,oBAAW,EAAC,sBAAsB,CAAC,EACnC,IAAA,iBAAU,EAAC,8BAAe,EAAE;QAC1B,IAAI,EAAE,iBAAc,CAAC,KAAK,CAAC,QAAQ;QACnC,OAAO;KACR,CAAC,EACF,IAAA,2BAAa,EAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QAC3B,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE;YAChB,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;SACzB;QAED,OAAO,IAAA,yBAAW,EAAC,KAAK,EAAE,EAAC,GAAG,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,EAAC,CAAC,CAAC;IACnE,CAAC,CAAC,EACF,IAAA,yBAAW,EAAC,CAAC,KAAU,EAAE,GAAG,EAAE,EAAE;QAC9B,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE;YAChB,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;SACzB;QAED,OAAO,IAAA,uBAAS,EAAC,KAAK,EAAE,EAAC,GAAG,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,EAAC,CAAC,CAAC;IACjE,CAAC,CAAC,EACF,IAAA,cAAK,EAAC,IAAA,eAAM,GAAE,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC,WAAW,CAAC,sBAAsB,CAAC,EAAE,GAAG,KAAK,CAAC,CAC7E,CAAC;AACzB,CAAC;AAzBD,gCAyBC"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ExcludeIndexes = void 0;
|
|
4
|
-
const schema_js_1 = require("./schema.js");
|
|
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_js_1.MongooseSchema)({ excludeIndexes });
|
|
26
|
-
}
|
|
27
|
-
exports.ExcludeIndexes = ExcludeIndexes;
|
|
28
|
-
//# sourceMappingURL=excludeIndexes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"excludeIndexes.js","sourceRoot":"","sources":["../../../src/decorators/excludeIndexes.ts"],"names":[],"mappings":";;;AAAA,2CAA2C;AAE3C;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,cAAc,CAAC,iBAA0B,IAAI;IAC3D,OAAO,IAAA,0BAAc,EAAC,EAAC,cAAc,EAAQ,CAAC,CAAC;AACjD,CAAC;AAFD,wCAEC"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Expires = void 0;
|
|
4
|
-
const schema_js_1 = require("./schema.js");
|
|
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_js_1.MongooseSchema)({ expires });
|
|
26
|
-
}
|
|
27
|
-
exports.Expires = Expires;
|
|
28
|
-
//# sourceMappingURL=expires.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"expires.js","sourceRoot":"","sources":["../../../src/decorators/expires.ts"],"names":[],"mappings":";;;AAAA,2CAA2C;AAE3C;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,OAAO,CAAC,OAA+B;IACrD,OAAO,IAAA,0BAAc,EAAC,EAAC,OAAO,EAAQ,CAAC,CAAC;AAC1C,CAAC;AAFD,0BAEC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Immutable = 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
|
-
* @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_js_1.MongooseSchema)({ immutable });
|
|
28
|
-
}
|
|
29
|
-
exports.Immutable = Immutable;
|
|
30
|
-
//# sourceMappingURL=immutable.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"immutable.js","sourceRoot":"","sources":["../../../src/decorators/immutable.ts"],"names":[],"mappings":";;;AAAA,2CAA2C;AAE3C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,SAAS,CAAC,YAA0D,IAAI;IACtF,OAAO,IAAA,0BAAc,EAAC,EAAC,SAAS,EAAQ,CAAC,CAAC;AAC5C,CAAC;AAFD,8BAEC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Indexed = void 0;
|
|
4
|
-
const schema_js_1 = require("./schema.js");
|
|
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_js_1.MongooseSchema)({ index });
|
|
24
|
-
}
|
|
25
|
-
exports.Indexed = Indexed;
|
|
26
|
-
//# sourceMappingURL=indexed.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"indexed.js","sourceRoot":"","sources":["../../../src/decorators/indexed.ts"],"names":[],"mappings":";;;AACA,2CAA2C;AAE3C;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,OAAO,CAAC,QAAyC,IAAI;IACnE,OAAO,IAAA,0BAAc,EAAC,EAAC,KAAK,EAAQ,CAAC,CAAC;AACxC,CAAC;AAFD,0BAEC"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Lowercase = void 0;
|
|
4
|
-
const schema_js_1 = require("./schema.js");
|
|
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_js_1.MongooseSchema)({ lowercase });
|
|
26
|
-
}
|
|
27
|
-
exports.Lowercase = Lowercase;
|
|
28
|
-
//# sourceMappingURL=lowercase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lowercase.js","sourceRoot":"","sources":["../../../src/decorators/lowercase.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,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Model = 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 MongooseConnections_js_1 = require("../services/MongooseConnections.js");
|
|
8
|
-
const createModel_js_1 = require("../utils/createModel.js");
|
|
9
|
-
const createSchema_js_1 = require("../utils/createSchema.js");
|
|
10
|
-
const schemaOptions_js_1 = require("../utils/schemaOptions.js");
|
|
11
|
-
/**
|
|
12
|
-
* Define a class as a Mongoose Model. The model can be injected to the Service, Controller, Middleware, Converters or Filter with
|
|
13
|
-
* `@Inject` annotation.
|
|
14
|
-
*
|
|
15
|
-
* ### Example
|
|
16
|
-
*
|
|
17
|
-
* ```typescript
|
|
18
|
-
* @Model()
|
|
19
|
-
* export class EventModel {
|
|
20
|
-
* @Property()
|
|
21
|
-
* field: string;
|
|
22
|
-
* }
|
|
23
|
-
* ```
|
|
24
|
-
*
|
|
25
|
-
* Then inject the model into a service:
|
|
26
|
-
*
|
|
27
|
-
* ```typescript
|
|
28
|
-
* class MyService {
|
|
29
|
-
* constructor(@Inject(EventModel) eventModel: MongooseModel<EventModel>) {
|
|
30
|
-
* eventModel.findById().exec();
|
|
31
|
-
* }
|
|
32
|
-
* }
|
|
33
|
-
* ```
|
|
34
|
-
*
|
|
35
|
-
* ### Options
|
|
36
|
-
*
|
|
37
|
-
* - `schemaOptions` (mongoose.SchemaOptions): Option to configure the schema behavior.
|
|
38
|
-
* - `name` (String): model name.
|
|
39
|
-
* - `collection` (String): collection (optional, induced from model name).
|
|
40
|
-
* - `skipInit` (Boolean): skipInit whether to skip initialization (defaults to false).
|
|
41
|
-
*
|
|
42
|
-
* @param {MongooseModelOptions} options
|
|
43
|
-
* @returns {(target: any) => void}
|
|
44
|
-
* @decorator
|
|
45
|
-
* @mongoose
|
|
46
|
-
* @class
|
|
47
|
-
*/
|
|
48
|
-
function Model(options = {}) {
|
|
49
|
-
return (0, core_1.useDecorators)((target) => {
|
|
50
|
-
const { token, collectionName } = (0, createModel_js_1.getModelToken)(target, options);
|
|
51
|
-
options.discriminatorValue && (0, schema_1.DiscriminatorValue)(options.discriminatorValue)(target);
|
|
52
|
-
(0, di_1.registerProvider)({
|
|
53
|
-
provide: token,
|
|
54
|
-
deps: [],
|
|
55
|
-
useFactory() {
|
|
56
|
-
return (0, createSchema_js_1.getSchema)(target, options);
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
(0, di_1.registerProvider)({
|
|
60
|
-
provide: target,
|
|
61
|
-
type: "mongoose:model",
|
|
62
|
-
deps: [MongooseConnections_js_1.MONGOOSE_CONNECTIONS, token],
|
|
63
|
-
useFactory(connections, schema) {
|
|
64
|
-
(0, schemaOptions_js_1.applySchemaOptions)(schema, (0, schemaOptions_js_1.schemaOptions)(target));
|
|
65
|
-
return (0, createModel_js_1.createModel)(target, schema, collectionName, options.collection, options.overwriteModels, connections.get(options.connection));
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
exports.Model = Model;
|
|
71
|
-
//# sourceMappingURL=model.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../../src/decorators/model.ts"],"names":[],"mappings":";;;AAAA,qCAAiD;AACjD,iCAA0C;AAC1C,yCAAgD;AAGhD,+EAAwE;AACxE,4DAAmE;AACnE,8DAAmD;AACnD,gEAA4E;AAE5E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,8BAAa,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,2BAAS,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,6CAAoB,EAAE,KAAK,CAAC;YACnC,UAAU,CAAC,WAAiC,EAAE,MAAc;gBAC1D,IAAA,qCAAkB,EAAC,MAAM,EAAE,IAAA,gCAAa,EAAC,MAAM,CAAC,CAAC,CAAC;gBAClD,OAAO,IAAA,4BAAW,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"}
|