@tsed/mongoose 8.0.0-alpha.1 → 8.0.0-alpha.10
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,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.applySchemaOptions = exports.buildPreHook = exports.schemaOptions = void 0;
|
|
4
|
-
const core_1 = require("@tsed/core");
|
|
5
|
-
const constants_js_1 = require("../constants/constants.js");
|
|
6
|
-
/**
|
|
7
|
-
* @ignore
|
|
8
|
-
*/
|
|
9
|
-
function schemaOptions(target, options) {
|
|
10
|
-
const store = core_1.Store.from(target);
|
|
11
|
-
if (!store.has(constants_js_1.MONGOOSE_SCHEMA_OPTIONS)) {
|
|
12
|
-
store.set(constants_js_1.MONGOOSE_SCHEMA_OPTIONS, {});
|
|
13
|
-
}
|
|
14
|
-
if (options) {
|
|
15
|
-
store.set(constants_js_1.MONGOOSE_SCHEMA_OPTIONS, (0, core_1.deepMerge)(store.get(constants_js_1.MONGOOSE_SCHEMA_OPTIONS), options));
|
|
16
|
-
}
|
|
17
|
-
return store.get(constants_js_1.MONGOOSE_SCHEMA_OPTIONS);
|
|
18
|
-
}
|
|
19
|
-
exports.schemaOptions = schemaOptions;
|
|
20
|
-
function mapHookArgs(hook) {
|
|
21
|
-
return [hook.method, hook.options || hook.fn, hook.options ? hook.fn : undefined].filter(Boolean);
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* @ignore
|
|
25
|
-
*/
|
|
26
|
-
function buildPreHook(fn) {
|
|
27
|
-
return fn.length === 1
|
|
28
|
-
? function () {
|
|
29
|
-
return fn(this);
|
|
30
|
-
}
|
|
31
|
-
: function (next) {
|
|
32
|
-
return fn(this, next);
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
exports.buildPreHook = buildPreHook;
|
|
36
|
-
/**
|
|
37
|
-
* @ignore
|
|
38
|
-
*/
|
|
39
|
-
function applySchemaOptions(schema, options) {
|
|
40
|
-
if (options.plugins) {
|
|
41
|
-
options.plugins.forEach((item) => schema.plugin(item.plugin, item.options));
|
|
42
|
-
}
|
|
43
|
-
if (options.indexes) {
|
|
44
|
-
options.indexes.forEach((item) => schema.index(item.fields, item.options));
|
|
45
|
-
}
|
|
46
|
-
if (options.pre) {
|
|
47
|
-
options.pre.forEach((item) => {
|
|
48
|
-
item = {
|
|
49
|
-
...item,
|
|
50
|
-
fn: buildPreHook(item.fn)
|
|
51
|
-
};
|
|
52
|
-
schema.pre(...mapHookArgs(item));
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
if (options.post) {
|
|
56
|
-
options.post.forEach((item) => schema.post(...mapHookArgs(item)));
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
exports.applySchemaOptions = applySchemaOptions;
|
|
60
|
-
//# sourceMappingURL=schemaOptions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schemaOptions.js","sourceRoot":"","sources":["../../../src/utils/schemaOptions.ts"],"names":[],"mappings":";;;AAAA,qCAA4C;AAE5C,4DAAkE;AAUlE;;GAEG;AACH,SAAgB,aAAa,CAAC,MAAW,EAAE,OAA+B;IACxE,MAAM,KAAK,GAAG,YAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAEjC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,sCAAuB,CAAC,EAAE;QACvC,KAAK,CAAC,GAAG,CAAC,sCAAuB,EAAE,EAAE,CAAC,CAAC;KACxC;IAED,IAAI,OAAO,EAAE;QACX,KAAK,CAAC,GAAG,CAAC,sCAAuB,EAAE,IAAA,gBAAS,EAAC,KAAK,CAAC,GAAG,CAAC,sCAAuB,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;KAC5F;IAED,OAAO,KAAK,CAAC,GAAG,CAAC,sCAAuB,CAAC,CAAC;AAC5C,CAAC;AAZD,sCAYC;AAED,SAAS,WAAW,CAAC,IAAwC;IAC3D,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAQ,CAAC;AAC3G,CAAC;AAED;;GAEG;AACH,SAAgB,YAAY,CAAC,EAAqB;IAChD,OAAO,EAAE,CAAC,MAAM,KAAK,CAAC;QACpB,CAAC,CAAC;YACE,OAAQ,EAA2B,CAAC,IAAI,CAAC,CAAC;QAC5C,CAAC;QACH,CAAC,CAAC,UAAU,IAAoB;YAC5B,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACxB,CAAC,CAAC;AACR,CAAC;AARD,oCAQC;AAED;;GAEG;AACH,SAAgB,kBAAkB,CAAC,MAAc,EAAE,OAA8B;IAC/E,IAAI,OAAO,CAAC,OAAO,EAAE;QACnB,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;KAC7E;IAED,IAAI,OAAO,CAAC,OAAO,EAAE;QACnB,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;KAC5E;IAED,IAAI,OAAO,CAAC,GAAG,EAAE;QACf,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YAC3B,IAAI,GAAG;gBACL,GAAG,IAAI;gBACP,EAAE,EAAE,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;aAC1B,CAAC;YAED,MAAM,CAAC,GAAW,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;KACJ;IAED,IAAI,OAAO,CAAC,IAAI,EAAE;QAChB,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAE,MAAM,CAAC,IAAY,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KAC5E;AACH,CAAC;AAvBD,gDAuBC"}
|
package/lib/esm/package.json
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Configuration, OnInit } from "@tsed/di";
|
|
2
|
-
import { OnDestroy } from "@tsed/di";
|
|
3
|
-
import { MongooseService } from "./services/MongooseService.js";
|
|
4
|
-
/**
|
|
5
|
-
* @ignore
|
|
6
|
-
*/
|
|
7
|
-
export declare class MongooseModule implements OnDestroy, OnInit {
|
|
8
|
-
private mongooseService;
|
|
9
|
-
private settings;
|
|
10
|
-
constructor(mongooseService: MongooseService, settings: Configuration);
|
|
11
|
-
$onInit(): void | Promise<any>;
|
|
12
|
-
$onDestroy(): Promise<any> | void;
|
|
13
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @type {string}
|
|
4
|
-
*/
|
|
5
|
-
export declare const MONGOOSE_SCHEMA = "tsed:mongoose:schema";
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
* @type {string}
|
|
9
|
-
*/
|
|
10
|
-
export declare const MONGOOSE_SCHEMA_OPTIONS = "tsed:mongoose:schema:options";
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
* @type {string}
|
|
14
|
-
*/
|
|
15
|
-
export declare const MONGOOSE_MODEL = "tsed:mongoose:model";
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
* @type {string}
|
|
19
|
-
*/
|
|
20
|
-
export declare const MONGOOSE_MODEL_NAME = "tsed:mongoose:model:name";
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* If true, uses Mongoose's default _id settings. Only allowed for ObjectIds
|
|
3
|
-
*
|
|
4
|
-
* ### Example
|
|
5
|
-
*
|
|
6
|
-
* ```typescript
|
|
7
|
-
* @Model()
|
|
8
|
-
* export class EventModel {
|
|
9
|
-
* @ExcludeIndexes()
|
|
10
|
-
* field: string;
|
|
11
|
-
* }
|
|
12
|
-
* ```
|
|
13
|
-
*
|
|
14
|
-
* @param {boolean} auto
|
|
15
|
-
* @returns {Function}
|
|
16
|
-
* @decorator
|
|
17
|
-
* @mongoose
|
|
18
|
-
* @property
|
|
19
|
-
*/
|
|
20
|
-
export declare function Auto(auto?: boolean): PropertyDecorator;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { DiscriminatorKey } from "@tsed/schema";
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { Type } from "@tsed/core";
|
|
2
|
-
/**
|
|
3
|
-
* Define a property as mongoose reference to other Model (decorated with @Model).
|
|
4
|
-
*
|
|
5
|
-
* ### Example
|
|
6
|
-
*
|
|
7
|
-
* ```typescript
|
|
8
|
-
* @Model()
|
|
9
|
-
* class FooModel {
|
|
10
|
-
*
|
|
11
|
-
* @DynamicRef('type')
|
|
12
|
-
* field: DynamicRef<OtherFooModel | OtherModel>
|
|
13
|
-
*
|
|
14
|
-
* @Enum(['OtherFooModel', 'OtherModel'])
|
|
15
|
-
* type: string
|
|
16
|
-
* }
|
|
17
|
-
*
|
|
18
|
-
* @Model()
|
|
19
|
-
* class OtherFooModel {
|
|
20
|
-
* }
|
|
21
|
-
*
|
|
22
|
-
* @Model()
|
|
23
|
-
* class OtherModel {
|
|
24
|
-
* }
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
|
-
* @param refPath {String} the path to apply the correct model
|
|
28
|
-
* @param types {Type} the classes to generate the correct json schema
|
|
29
|
-
* @returns {Function}
|
|
30
|
-
* @decorator
|
|
31
|
-
* @mongoose
|
|
32
|
-
* @property
|
|
33
|
-
*/
|
|
34
|
-
export declare function DynamicRef(refPath: string, ...types: Type<any>[]): PropertyDecorator;
|
|
35
|
-
export type DynamicRef<T> = T | string;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* If true, Mongoose will skip gathering indexes on subpaths. Only allowed for subdocuments and subdocument arrays.
|
|
3
|
-
*
|
|
4
|
-
* ### Example
|
|
5
|
-
*
|
|
6
|
-
* ```typescript
|
|
7
|
-
* @Model()
|
|
8
|
-
* export class EventModel {
|
|
9
|
-
* @ExcludeIndexes()
|
|
10
|
-
* field: string;
|
|
11
|
-
* }
|
|
12
|
-
* ```
|
|
13
|
-
*
|
|
14
|
-
* @param {boolean} excludeIndexes
|
|
15
|
-
* @returns {Function}
|
|
16
|
-
* @decorator
|
|
17
|
-
* @mongoose
|
|
18
|
-
* @property
|
|
19
|
-
*/
|
|
20
|
-
export declare function ExcludeIndexes(excludeIndexes?: boolean): PropertyDecorator;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Defines a TTL index on this path. Only allowed for dates.
|
|
3
|
-
*
|
|
4
|
-
* ### Example
|
|
5
|
-
*
|
|
6
|
-
* ```typescript
|
|
7
|
-
* @Model()
|
|
8
|
-
* export class EventModel {
|
|
9
|
-
* @Expires('5d')
|
|
10
|
-
* field: string;
|
|
11
|
-
* }
|
|
12
|
-
* ```
|
|
13
|
-
*
|
|
14
|
-
* @param {boolean | any} expires
|
|
15
|
-
* @returns {Function}
|
|
16
|
-
* @decorator
|
|
17
|
-
* @mongoose
|
|
18
|
-
* @property
|
|
19
|
-
*/
|
|
20
|
-
export declare function Expires(expires: number | string | Date): PropertyDecorator;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* If [truthy](https://masteringjs.io/tutorials/fundamentals/truthy), Mongoose will
|
|
3
|
-
* disallow changes to this path once the document is saved to the database for the first time. Read more
|
|
4
|
-
* about [immutability in Mongoose here](http://thecodebarbarian.com/whats-new-in-mongoose-5-6-immutable-properties.html).
|
|
5
|
-
*
|
|
6
|
-
* ### Example
|
|
7
|
-
*
|
|
8
|
-
* ```typescript
|
|
9
|
-
* @Model()
|
|
10
|
-
* export class EventModel {
|
|
11
|
-
* @Immutable()
|
|
12
|
-
* field: string;
|
|
13
|
-
* }
|
|
14
|
-
* ```
|
|
15
|
-
*
|
|
16
|
-
* @param {boolean | any} immutable
|
|
17
|
-
* @returns {Function}
|
|
18
|
-
* @decorator
|
|
19
|
-
* @mongoose
|
|
20
|
-
* @property
|
|
21
|
-
*/
|
|
22
|
-
export declare function Immutable(immutable?: boolean | ((this: any, doc: any) => boolean)): PropertyDecorator;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { IndexOptions } from "mongoose";
|
|
2
|
-
/**
|
|
3
|
-
* Tell Mongoose whether to define an index for the property.
|
|
4
|
-
* ### Example
|
|
5
|
-
*
|
|
6
|
-
* ```typescript
|
|
7
|
-
* @Model()
|
|
8
|
-
* export class EventModel {
|
|
9
|
-
* @Indexed()
|
|
10
|
-
* field: string;
|
|
11
|
-
* }
|
|
12
|
-
* ```
|
|
13
|
-
*
|
|
14
|
-
* @returns {Function}
|
|
15
|
-
* @decorator
|
|
16
|
-
* @mongoose
|
|
17
|
-
* @property
|
|
18
|
-
*/
|
|
19
|
-
export declare function Indexed(index?: IndexOptions | boolean | string): PropertyDecorator;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* If truthy, Mongoose will add a custom setter that lowercases this string using JavaScript's built-in String#toLowerCase().
|
|
3
|
-
*
|
|
4
|
-
* ### Example
|
|
5
|
-
*
|
|
6
|
-
* ```typescript
|
|
7
|
-
* @Model()
|
|
8
|
-
* export class EventModel {
|
|
9
|
-
* @Lowercase()
|
|
10
|
-
* field: string;
|
|
11
|
-
* }
|
|
12
|
-
* ```
|
|
13
|
-
*
|
|
14
|
-
* @param {boolean} lowercase
|
|
15
|
-
* @returns {Function}
|
|
16
|
-
* @decorator
|
|
17
|
-
* @mongoose
|
|
18
|
-
* @property
|
|
19
|
-
*/
|
|
20
|
-
export declare function Lowercase(lowercase?: boolean): PropertyDecorator;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { MongooseModelOptions } from "../interfaces/MongooseModelOptions.js";
|
|
2
|
-
/**
|
|
3
|
-
* Define a class as a Mongoose Model. The model can be injected to the Service, Controller, Middleware, Converters or Filter with
|
|
4
|
-
* `@Inject` annotation.
|
|
5
|
-
*
|
|
6
|
-
* ### Example
|
|
7
|
-
*
|
|
8
|
-
* ```typescript
|
|
9
|
-
* @Model()
|
|
10
|
-
* export class EventModel {
|
|
11
|
-
* @Property()
|
|
12
|
-
* field: string;
|
|
13
|
-
* }
|
|
14
|
-
* ```
|
|
15
|
-
*
|
|
16
|
-
* Then inject the model into a service:
|
|
17
|
-
*
|
|
18
|
-
* ```typescript
|
|
19
|
-
* class MyService {
|
|
20
|
-
* constructor(@Inject(EventModel) eventModel: MongooseModel<EventModel>) {
|
|
21
|
-
* eventModel.findById().exec();
|
|
22
|
-
* }
|
|
23
|
-
* }
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* ### Options
|
|
27
|
-
*
|
|
28
|
-
* - `schemaOptions` (mongoose.SchemaOptions): Option to configure the schema behavior.
|
|
29
|
-
* - `name` (String): model name.
|
|
30
|
-
* - `collection` (String): collection (optional, induced from model name).
|
|
31
|
-
* - `skipInit` (Boolean): skipInit whether to skip initialization (defaults to false).
|
|
32
|
-
*
|
|
33
|
-
* @param {MongooseModelOptions} options
|
|
34
|
-
* @returns {(target: any) => void}
|
|
35
|
-
* @decorator
|
|
36
|
-
* @mongoose
|
|
37
|
-
* @class
|
|
38
|
-
*/
|
|
39
|
-
export declare function Model(options?: MongooseModelOptions): any;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Calls schema.index() to define an index (most likely compound) for the schema.
|
|
3
|
-
*
|
|
4
|
-
* ### Example
|
|
5
|
-
*
|
|
6
|
-
* ```typescript
|
|
7
|
-
* @Model()
|
|
8
|
-
* @MongooseIndex({first: 1, second: 1}, {unique: 1})
|
|
9
|
-
* export class EventModel {
|
|
10
|
-
*
|
|
11
|
-
* @Property()
|
|
12
|
-
* first: string;
|
|
13
|
-
*
|
|
14
|
-
* @Property()
|
|
15
|
-
* second: string;
|
|
16
|
-
*
|
|
17
|
-
* }
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* @param fields
|
|
21
|
-
* @param options
|
|
22
|
-
* @returns {Function}
|
|
23
|
-
* @decorator
|
|
24
|
-
* @mongoose
|
|
25
|
-
* @class
|
|
26
|
-
*/
|
|
27
|
-
export declare function MongooseIndex(fields: object, options?: any): Function;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Calls schema.index() to define multiple indexes (most likely compound) for the schema.
|
|
3
|
-
*
|
|
4
|
-
* ### Example
|
|
5
|
-
*
|
|
6
|
-
* ```typescript
|
|
7
|
-
* @Model()
|
|
8
|
-
* @MongooseIndexes([{fields: {first: 1, second: 1}, options:{unique: 1}}, {fields: {first: 1, third: 1}, options:{unique: 1}}])
|
|
9
|
-
* export class EventModel {
|
|
10
|
-
*
|
|
11
|
-
* @Property()
|
|
12
|
-
* first: string;
|
|
13
|
-
*
|
|
14
|
-
* @Property()
|
|
15
|
-
* second: string;
|
|
16
|
-
*
|
|
17
|
-
* @Property()
|
|
18
|
-
* third: string;
|
|
19
|
-
*
|
|
20
|
-
* }
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* @param indexes - define multiple mongoose indexes
|
|
24
|
-
* @returns {Function}
|
|
25
|
-
* @decorator
|
|
26
|
-
* @mongoose
|
|
27
|
-
* @class
|
|
28
|
-
*/
|
|
29
|
-
export declare function MongooseIndexes(indexes: Array<{
|
|
30
|
-
fields: object;
|
|
31
|
-
options?: any;
|
|
32
|
-
}>): Function;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import mongoose from "mongoose";
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
* @param {(schema: "mongoose".Schema, options?: any) => void} plugin
|
|
5
|
-
* @param options
|
|
6
|
-
* @returns {Function}
|
|
7
|
-
* @decorator
|
|
8
|
-
* @mongoose
|
|
9
|
-
* @class
|
|
10
|
-
*/
|
|
11
|
-
export declare function MongoosePlugin(plugin: (schema: mongoose.Schema, options?: any) => void, options?: any): Function;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { FormatsMethods } from "@tsed/ajv";
|
|
2
|
-
import { Types } from "mongoose";
|
|
3
|
-
export declare class DecimalFormat implements FormatsMethods<string | number> {
|
|
4
|
-
validate(num: string | number): boolean;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Tell Mongoose whether to define an Decimal128 property.
|
|
8
|
-
* Will be serialized as `number` with format as `decimal`.
|
|
9
|
-
* ### Example
|
|
10
|
-
*
|
|
11
|
-
* ```typescript
|
|
12
|
-
* @Model()
|
|
13
|
-
* export class PriceModel {
|
|
14
|
-
* @NumberDecimal()
|
|
15
|
-
* price: Decimal128;
|
|
16
|
-
* }
|
|
17
|
-
* ```
|
|
18
|
-
* Optionally using custom decimal type, such as `Big` from big.js
|
|
19
|
-
* ```typescript
|
|
20
|
-
* @Model()
|
|
21
|
-
* export class PriceModel {
|
|
22
|
-
* @NumberDecimal(Big)
|
|
23
|
-
* price: Big;
|
|
24
|
-
* }
|
|
25
|
-
* ```
|
|
26
|
-
* @param type Optional decimal type constructor
|
|
27
|
-
* @decorator
|
|
28
|
-
* @mongoose
|
|
29
|
-
* @schema
|
|
30
|
-
*/
|
|
31
|
-
export declare function NumberDecimal(type?: any): any;
|
|
32
|
-
export type Decimal128 = Types.Decimal128;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Types } from "mongoose";
|
|
2
|
-
/**
|
|
3
|
-
* Tell Mongoose whether to define an ObjectId property.
|
|
4
|
-
* ### Example
|
|
5
|
-
*
|
|
6
|
-
* ```typescript
|
|
7
|
-
* @Model()
|
|
8
|
-
* export class EventModel {
|
|
9
|
-
* @ObjectId('id')
|
|
10
|
-
* _id: string;
|
|
11
|
-
* }
|
|
12
|
-
* ```
|
|
13
|
-
* @param name
|
|
14
|
-
* @decorator
|
|
15
|
-
* @mongoose
|
|
16
|
-
* @schema
|
|
17
|
-
*/
|
|
18
|
-
export declare function ObjectID(name?: string): any;
|
|
19
|
-
export type ObjectID = Types.ObjectId;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { StaticMethodDecorator } from "@tsed/core";
|
|
2
|
-
import { MongooseHookOptions, MongoosePostHookCB } from "../interfaces/MongooseSchemaOptions.js";
|
|
3
|
-
/**
|
|
4
|
-
* We can simply attach a `@PostHook` decorator to your model class and
|
|
5
|
-
* define the hook function like you normally would in Mongoose.
|
|
6
|
-
*
|
|
7
|
-
* ```typescript
|
|
8
|
-
* import {Ignore, Required} from "@tsed/common";
|
|
9
|
-
* import {PostHook, Model} from "@tsed/mongoose";
|
|
10
|
-
*
|
|
11
|
-
* @Model()
|
|
12
|
-
* @PostHook("save", (car: CarModel) => {
|
|
13
|
-
* if (car.topSpeedInKmH > 300) {
|
|
14
|
-
* console.log(car.model, 'is fast!');
|
|
15
|
-
* }
|
|
16
|
-
* })
|
|
17
|
-
* export class CarModel {
|
|
18
|
-
* @Ignore()
|
|
19
|
-
* _id: string;
|
|
20
|
-
*
|
|
21
|
-
* @Required()
|
|
22
|
-
* model: string;
|
|
23
|
-
*
|
|
24
|
-
* @Required()
|
|
25
|
-
* isFast: boolean;
|
|
26
|
-
*
|
|
27
|
-
* // or Prehook on static method
|
|
28
|
-
* @PostHook("save")
|
|
29
|
-
* static postSave(car: CarModel) {
|
|
30
|
-
* if (car.topSpeedInKmH > 300) {
|
|
31
|
-
* console.log(car.model, 'is fast!');
|
|
32
|
-
* }
|
|
33
|
-
* }
|
|
34
|
-
* }
|
|
35
|
-
* ```
|
|
36
|
-
*
|
|
37
|
-
* This will execute the post-save hook each time a `CarModel` document is saved.
|
|
38
|
-
*
|
|
39
|
-
* @param {string} method
|
|
40
|
-
* @param fn
|
|
41
|
-
* @returns {Function}
|
|
42
|
-
* @decorator
|
|
43
|
-
* @mongoose
|
|
44
|
-
* @class
|
|
45
|
-
*/
|
|
46
|
-
export declare function PostHook<T = any>(method: string, fn: MongoosePostHookCB<T>): ClassDecorator;
|
|
47
|
-
export declare function PostHook<T = any>(method: string, fn: MongoosePostHookCB<T>, options: MongooseHookOptions): ClassDecorator;
|
|
48
|
-
export declare function PostHook<T = any>(method: string, options: MongooseHookOptions): StaticMethodDecorator;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { MongooseHookOptions, MongoosePreHookCB } from "../interfaces/MongooseSchemaOptions.js";
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
* We can simply attach a `@PreHook` decorator to your model class and
|
|
5
|
-
* define the hook function like you normally would in Mongoose.
|
|
6
|
-
*
|
|
7
|
-
* ```typescript
|
|
8
|
-
* import {Ignore, Required} from "@tsed/common";
|
|
9
|
-
* import {PreHook, Model} from "@tsed/mongoose";
|
|
10
|
-
*
|
|
11
|
-
* @Model()
|
|
12
|
-
* @PreHook("save", (car: CarModel, next) => {
|
|
13
|
-
* if (car.model === 'Tesla') {
|
|
14
|
-
* car.isFast = true;
|
|
15
|
-
* }
|
|
16
|
-
* next();
|
|
17
|
-
*})
|
|
18
|
-
* export class CarModel {
|
|
19
|
-
*
|
|
20
|
-
* @Ignore()
|
|
21
|
-
* _id: string;
|
|
22
|
-
*
|
|
23
|
-
* @Required()
|
|
24
|
-
* model: string;
|
|
25
|
-
*
|
|
26
|
-
* @Required()
|
|
27
|
-
* isFast: boolean;
|
|
28
|
-
*
|
|
29
|
-
* // or Prehook on static method
|
|
30
|
-
* @PreHook("save")
|
|
31
|
-
* static preSave(car: CarModel, next) {
|
|
32
|
-
* if (car.model === 'Tesla') {
|
|
33
|
-
* car.isFast = true;
|
|
34
|
-
* }
|
|
35
|
-
* next();
|
|
36
|
-
* }
|
|
37
|
-
* }
|
|
38
|
-
* ```
|
|
39
|
-
*
|
|
40
|
-
* This will execute the pre-save hook each time a `CarModel` document is saved.
|
|
41
|
-
*
|
|
42
|
-
* @param {string} method
|
|
43
|
-
* @param fn
|
|
44
|
-
* @param options
|
|
45
|
-
* @returns {Function}
|
|
46
|
-
* @decorator
|
|
47
|
-
* @class
|
|
48
|
-
*/
|
|
49
|
-
export declare function PreHook<T = any>(method: string, fn?: MongoosePreHookCB<T> | MongooseHookOptions, options?: MongooseHookOptions): Function;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Type } from "@tsed/core";
|
|
2
|
-
import { MongooseSchemaTypes } from "../interfaces/MongooseSchemaTypes.js";
|
|
3
|
-
interface RefOptions {
|
|
4
|
-
type?: MongooseSchemaTypes;
|
|
5
|
-
populatedGroups?: string[];
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Define a property as mongoose reference to other Model (decorated with @Model).
|
|
9
|
-
*
|
|
10
|
-
* ### Example
|
|
11
|
-
*
|
|
12
|
-
* ```typescript
|
|
13
|
-
*
|
|
14
|
-
* @Model()
|
|
15
|
-
* class FooModel {
|
|
16
|
-
*
|
|
17
|
-
* @Ref(Foo2Model)
|
|
18
|
-
* field: Ref<Foo2Model>
|
|
19
|
-
*
|
|
20
|
-
* @Ref(Foo2Model)
|
|
21
|
-
* list: Ref<Foo2Model>[]
|
|
22
|
-
* }
|
|
23
|
-
*
|
|
24
|
-
* @Model()
|
|
25
|
-
* class Foo2Model {
|
|
26
|
-
* }
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
* @param model
|
|
30
|
-
* @param options
|
|
31
|
-
* @returns {Function}
|
|
32
|
-
* @decorator
|
|
33
|
-
* @mongoose
|
|
34
|
-
* @property
|
|
35
|
-
*/
|
|
36
|
-
export declare function Ref(model: string | (() => Type) | any, options?: RefOptions | MongooseSchemaTypes): PropertyDecorator;
|
|
37
|
-
export type Ref<T> = T | string;
|
|
38
|
-
export {};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { SchemaTypeOptions } from "mongoose";
|
|
2
|
-
import { MongooseSchemaOptions } from "../interfaces/MongooseSchemaOptions.js";
|
|
3
|
-
/**
|
|
4
|
-
* Define a class as a Mongoose Schema ready to be used to compose other schemes and models.
|
|
5
|
-
*
|
|
6
|
-
* ### Example
|
|
7
|
-
*
|
|
8
|
-
* ```typescript
|
|
9
|
-
* @MongooseSchema()
|
|
10
|
-
* export class EventSchema {
|
|
11
|
-
* @Property()
|
|
12
|
-
* field: string;
|
|
13
|
-
* }
|
|
14
|
-
* ```
|
|
15
|
-
*
|
|
16
|
-
* ### Options
|
|
17
|
-
*
|
|
18
|
-
* - `schemaOptions` (mongoose.SchemaOptions): Option to configure the schema behavior.
|
|
19
|
-
*
|
|
20
|
-
* @param {MongooseSchemaOptions | undefined} options
|
|
21
|
-
* @returns {(target: any) => void}
|
|
22
|
-
* @decorator
|
|
23
|
-
* @mongoose
|
|
24
|
-
* @property
|
|
25
|
-
* @class
|
|
26
|
-
*/
|
|
27
|
-
export declare function Schema(options?: MongooseSchemaOptions): (target: any) => void;
|
|
28
|
-
export declare function Schema(definition: SchemaTypeOptions<any>): Function;
|
|
29
|
-
/**
|
|
30
|
-
* Define a class as a Mongoose Schema ready to be used to compose other schemes and models.
|
|
31
|
-
*
|
|
32
|
-
* ### Example
|
|
33
|
-
*
|
|
34
|
-
* ```typescript
|
|
35
|
-
* @MongooseSchema()
|
|
36
|
-
* export class EventSchema {
|
|
37
|
-
* @Property()
|
|
38
|
-
* field: string;
|
|
39
|
-
* }
|
|
40
|
-
* ```
|
|
41
|
-
*
|
|
42
|
-
* ### Options
|
|
43
|
-
*
|
|
44
|
-
* - `schemaOptions` (mongoose.SchemaOptions): Option to configure the schema behavior.
|
|
45
|
-
*
|
|
46
|
-
* @param {MongooseSchemaOptions | undefined} options
|
|
47
|
-
* @returns {(target: any) => void}
|
|
48
|
-
* @decorator
|
|
49
|
-
* @mongoose
|
|
50
|
-
* @property
|
|
51
|
-
* @class
|
|
52
|
-
*/
|
|
53
|
-
export declare function MongooseSchema(options?: MongooseSchemaOptions): (target: any) => void;
|
|
54
|
-
export declare function MongooseSchema(definition: SchemaTypeOptions<any>): Function;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Do not apply this property to schema (create virtual property)
|
|
3
|
-
*
|
|
4
|
-
* ### Example
|
|
5
|
-
*
|
|
6
|
-
* ```typescript
|
|
7
|
-
* @Model()
|
|
8
|
-
* @SchemaIgnore()
|
|
9
|
-
* @Property()
|
|
10
|
-
* kind: string;
|
|
11
|
-
*
|
|
12
|
-
* ```
|
|
13
|
-
*
|
|
14
|
-
* @returns {Function}
|
|
15
|
-
* @decorator
|
|
16
|
-
* @mongoose
|
|
17
|
-
* @class
|
|
18
|
-
*/
|
|
19
|
-
export declare function SchemaIgnore(): Function;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tell Mongoose to set default select() behavior for this path.
|
|
3
|
-
*
|
|
4
|
-
* ### Example
|
|
5
|
-
*
|
|
6
|
-
* ```typescript
|
|
7
|
-
* @Model()
|
|
8
|
-
* export class EventModel {
|
|
9
|
-
* @Select()
|
|
10
|
-
* field: string;
|
|
11
|
-
* }
|
|
12
|
-
* ```
|
|
13
|
-
*
|
|
14
|
-
* @param {boolean | any} select
|
|
15
|
-
* @returns {Function}
|
|
16
|
-
* @decorator
|
|
17
|
-
* @mongoose
|
|
18
|
-
* @property
|
|
19
|
-
*/
|
|
20
|
-
export declare function Select(select?: boolean | any): Function;
|