@tsed/mongoose 7.0.0-beta.2 → 7.0.0-beta.20
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 +1 -1
- package/lib/cjs/MongooseModule.js +6 -4
- package/lib/cjs/MongooseModule.js.map +1 -1
- package/lib/cjs/constants/{index.js → constants.js} +1 -1
- package/lib/cjs/constants/constants.js.map +1 -0
- package/lib/cjs/decorators/discriminatorKey.js +1 -1
- package/lib/cjs/decorators/discriminatorKey.js.map +1 -1
- package/lib/cjs/decorators/dynamicRef.js +24 -5
- package/lib/cjs/decorators/dynamicRef.js.map +1 -1
- package/lib/cjs/decorators/model.js +5 -4
- package/lib/cjs/decorators/model.js.map +1 -1
- package/lib/cjs/decorators/numberDecimal.js +2 -2
- package/lib/cjs/decorators/numberDecimal.js.map +1 -1
- package/lib/cjs/decorators/objectID.js +1 -1
- package/lib/cjs/decorators/objectID.js.map +1 -1
- package/lib/cjs/decorators/postHook.js.map +1 -1
- package/lib/cjs/decorators/preHook.js.map +1 -1
- package/lib/cjs/decorators/ref.js +5 -2
- package/lib/cjs/decorators/ref.js.map +1 -1
- package/lib/cjs/decorators/schema.js +1 -1
- package/lib/cjs/decorators/schema.js.map +1 -1
- package/lib/cjs/decorators/versionKey.js +1 -1
- package/lib/cjs/decorators/versionKey.js.map +1 -1
- package/lib/cjs/decorators/virtualRef.js +1 -1
- package/lib/cjs/decorators/virtualRef.js.map +1 -1
- package/lib/cjs/index.js +47 -6
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/interfaces/MongooseModel.js.map +1 -1
- package/lib/cjs/interfaces/MongooseModelOptions.js.map +1 -1
- package/lib/cjs/interfaces/MongooseSchemaOptions.js.map +1 -1
- package/lib/cjs/interfaces/interfaces.js +3 -0
- package/lib/cjs/interfaces/interfaces.js.map +1 -0
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/services/MongooseConnections.js +1 -5
- package/lib/cjs/services/MongooseConnections.js.map +1 -1
- package/lib/cjs/services/MongooseService.js +7 -8
- package/lib/cjs/services/MongooseService.js.map +1 -1
- package/lib/cjs/utils/createModel.js +7 -11
- package/lib/cjs/utils/createModel.js.map +1 -1
- package/lib/cjs/utils/createSchema.js +5 -5
- package/lib/cjs/utils/createSchema.js.map +1 -1
- package/lib/cjs/utils/resolveRefType.js +1 -1
- package/lib/cjs/utils/resolveRefType.js.map +1 -1
- package/lib/cjs/utils/schemaOptions.js +1 -1
- package/lib/cjs/utils/schemaOptions.js.map +1 -1
- package/lib/esm/MongooseModule.js +5 -3
- package/lib/esm/MongooseModule.js.map +1 -1
- package/lib/esm/constants/{index.js → constants.js} +1 -1
- package/lib/esm/constants/constants.js.map +1 -0
- package/lib/esm/decorators/auto.js +1 -1
- package/lib/esm/decorators/discriminatorKey.js +2 -2
- package/lib/esm/decorators/discriminatorKey.js.map +1 -1
- package/lib/esm/decorators/dynamicRef.js +26 -7
- package/lib/esm/decorators/dynamicRef.js.map +1 -1
- package/lib/esm/decorators/excludeIndexes.js +1 -1
- package/lib/esm/decorators/expires.js +1 -1
- package/lib/esm/decorators/immutable.js +1 -1
- package/lib/esm/decorators/indexed.js +1 -1
- package/lib/esm/decorators/lowercase.js +1 -1
- package/lib/esm/decorators/model.js +5 -4
- package/lib/esm/decorators/model.js.map +1 -1
- package/lib/esm/decorators/mongooseIndex.js +1 -1
- package/lib/esm/decorators/mongooseIndexes.js +1 -1
- package/lib/esm/decorators/mongoosePlugin.js +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 +1 -1
- package/lib/esm/decorators/objectID.js.map +1 -1
- package/lib/esm/decorators/postHook.js +1 -1
- package/lib/esm/decorators/postHook.js.map +1 -1
- package/lib/esm/decorators/preHook.js +1 -1
- package/lib/esm/decorators/preHook.js.map +1 -1
- package/lib/esm/decorators/ref.js +7 -4
- package/lib/esm/decorators/ref.js.map +1 -1
- package/lib/esm/decorators/schema.js +2 -2
- package/lib/esm/decorators/schema.js.map +1 -1
- package/lib/esm/decorators/schemaIgnore.js +1 -1
- package/lib/esm/decorators/select.js +1 -1
- package/lib/esm/decorators/sparse.js +1 -1
- package/lib/esm/decorators/text.js +1 -1
- package/lib/esm/decorators/trim.js +1 -1
- package/lib/esm/decorators/unique.js +1 -1
- package/lib/esm/decorators/uppercase.js +1 -1
- package/lib/esm/decorators/versionKey.js +1 -1
- package/lib/esm/decorators/versionKey.js.map +1 -1
- package/lib/esm/decorators/virtualRef.js +2 -2
- package/lib/esm/decorators/virtualRef.js.map +1 -1
- package/lib/esm/index.js +47 -6
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/interfaces/MongooseModel.js.map +1 -1
- package/lib/esm/interfaces/MongooseModelOptions.js.map +1 -1
- package/lib/esm/interfaces/MongooseSchemaOptions.js.map +1 -1
- package/lib/esm/interfaces/interfaces.js +2 -0
- package/lib/esm/interfaces/interfaces.js.map +1 -0
- package/lib/esm/package.json +3 -0
- package/lib/esm/services/MongooseConnections.js +2 -6
- package/lib/esm/services/MongooseConnections.js.map +1 -1
- package/lib/esm/services/MongooseService.js +3 -4
- package/lib/esm/services/MongooseService.js.map +1 -1
- package/lib/esm/utils/createModel.js +8 -12
- package/lib/esm/utils/createModel.js.map +1 -1
- package/lib/esm/utils/createSchema.js +6 -6
- package/lib/esm/utils/createSchema.js.map +1 -1
- package/lib/esm/utils/resolveRefType.js +1 -1
- package/lib/esm/utils/resolveRefType.js.map +1 -1
- package/lib/esm/utils/schemaOptions.js +1 -1
- package/lib/esm/utils/schemaOptions.js.map +1 -1
- package/lib/types/constants/{index.d.ts → constants.d.ts} +0 -0
- package/lib/types/decorators/dynamicRef.d.ts +4 -2
- package/lib/types/decorators/postHook.d.ts +1 -1
- package/lib/types/decorators/preHook.d.ts +1 -1
- package/lib/types/decorators/schema.d.ts +1 -1
- package/lib/types/decorators/virtualRef.d.ts +0 -4
- package/lib/types/index.d.ts +46 -5
- package/lib/types/interfaces/MongooseModel.d.ts +1 -2
- package/lib/types/interfaces/MongooseModelOptions.d.ts +1 -1
- package/lib/types/interfaces/MongooseSchemaOptions.d.ts +4 -4
- package/lib/types/interfaces/{index.d.ts → interfaces.d.ts} +0 -6
- package/lib/types/utils/createModel.d.ts +2 -2
- package/lib/types/utils/createSchema.d.ts +1 -1
- package/lib/types/utils/schemaOptions.d.ts +1 -1
- package/package.json +24 -19
- package/readme.md +127 -136
- package/tsconfig.compile.esm.json +2 -12
- package/lib/cjs/constants/index.js.map +0 -1
- package/lib/cjs/decorators/index.js +0 -30
- package/lib/cjs/decorators/index.js.map +0 -1
- package/lib/cjs/interfaces/index.js +0 -10
- package/lib/cjs/interfaces/index.js.map +0 -1
- package/lib/cjs/utils/index.js +0 -6
- package/lib/cjs/utils/index.js.map +0 -1
- package/lib/esm/constants/index.js.map +0 -1
- package/lib/esm/decorators/index.js +0 -27
- package/lib/esm/decorators/index.js.map +0 -1
- package/lib/esm/interfaces/index.js +0 -7
- package/lib/esm/interfaces/index.js.map +0 -1
- package/lib/esm/utils/index.js +0 -3
- package/lib/esm/utils/index.js.map +0 -1
- package/lib/types/decorators/index.d.ts +0 -26
- package/lib/types/utils/index.d.ts +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemaOptions.js","sourceRoot":"","sources":["../../../src/utils/schemaOptions.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"schemaOptions.js","sourceRoot":"","sources":["../../../src/utils/schemaOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,KAAK,EAAC,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAC,uBAAuB,EAAC,MAAM,wBAAwB,CAAC;AAG/D;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,MAAW,EAAE,OAA+B;IACxE,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAEjC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,uBAAuB,CAAC,EAAE;QACvC,KAAK,CAAC,GAAG,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC;KACxC;IAED,IAAI,OAAO,EAAE;QACX,KAAK,CAAC,GAAG,CAAC,uBAAuB,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,uBAAuB,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;KAC5F;IAED,OAAO,KAAK,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;AAC5C,CAAC;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,MAAM,UAAU,YAAY,CAAC,EAAY;IACvC,OAAO,EAAE,CAAC,MAAM,KAAK,CAAC;QACpB,CAAC,CAAC,UAAU,IAAoB;YAC5B,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACxB,CAAC;QACH,CAAC,CAAC,UAAU,IAAoB,EAAE,OAAY;YAC1C,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QACjC,CAAC,CAAC;AACR,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,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","sourcesContent":["import {deepMerge, Store} from \"@tsed/core\";\nimport {Schema} from \"mongoose\";\nimport {MONGOOSE_SCHEMA_OPTIONS} from \"../constants/constants\";\nimport {MongooseNextCB, MongoosePostHook, MongoosePreHook, MongooseSchemaOptions} from \"../interfaces/MongooseSchemaOptions\";\n\n/**\n * @ignore\n */\nexport function schemaOptions(target: any, options?: MongooseSchemaOptions) {\n const store = Store.from(target);\n\n if (!store.has(MONGOOSE_SCHEMA_OPTIONS)) {\n store.set(MONGOOSE_SCHEMA_OPTIONS, {});\n }\n\n if (options) {\n store.set(MONGOOSE_SCHEMA_OPTIONS, deepMerge(store.get(MONGOOSE_SCHEMA_OPTIONS), options));\n }\n\n return store.get(MONGOOSE_SCHEMA_OPTIONS);\n}\n\nfunction mapHookArgs(hook: MongoosePreHook | MongoosePostHook): [string | RegExp, Function] {\n return [hook.method, hook.options || hook.fn, hook.options ? hook.fn : undefined].filter(Boolean) as any;\n}\n\n/**\n * @ignore\n */\nexport function buildPreHook(fn: Function) {\n return fn.length === 2\n ? function (next: MongooseNextCB) {\n return fn(this, next);\n }\n : function (next: MongooseNextCB, options: any) {\n return fn(this, next, options);\n };\n}\n\n/**\n * @ignore\n */\nexport function applySchemaOptions(schema: Schema, options: MongooseSchemaOptions) {\n if (options.plugins) {\n options.plugins.forEach((item) => schema.plugin(item.plugin, item.options));\n }\n\n if (options.indexes) {\n options.indexes.forEach((item) => schema.index(item.fields, item.options));\n }\n\n if (options.pre) {\n options.pre.forEach((item) => {\n item = {\n ...item,\n fn: buildPreHook(item.fn)\n };\n\n (schema.pre as any)(...mapHookArgs(item));\n });\n }\n\n if (options.post) {\n options.post.forEach((item) => (schema.post as any)(...mapHookArgs(item)));\n }\n}\n"]}
|
|
File without changes
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Type } from "@tsed/core";
|
|
1
2
|
/**
|
|
2
3
|
* Define a property as mongoose reference to other Model (decorated with @Model).
|
|
3
4
|
*
|
|
@@ -23,11 +24,12 @@
|
|
|
23
24
|
* }
|
|
24
25
|
* ```
|
|
25
26
|
*
|
|
26
|
-
* @param refPath
|
|
27
|
+
* @param refPath {String} the path to apply the correct model
|
|
28
|
+
* @param types {Type} the classes to generate the correct json schema
|
|
27
29
|
* @returns {Function}
|
|
28
30
|
* @decorator
|
|
29
31
|
* @mongoose
|
|
30
32
|
* @property
|
|
31
33
|
*/
|
|
32
|
-
export declare function DynamicRef(refPath: string): PropertyDecorator;
|
|
34
|
+
export declare function DynamicRef(refPath: string, ...types: Type<any>[]): PropertyDecorator;
|
|
33
35
|
export declare type DynamicRef<T> = T | string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StaticMethodDecorator } from "@tsed/core";
|
|
2
|
-
import { MongooseHookOptions, MongoosePostHookCB } from "../interfaces";
|
|
2
|
+
import { MongooseHookOptions, MongoosePostHookCB } from "../interfaces/MongooseSchemaOptions";
|
|
3
3
|
/**
|
|
4
4
|
* We can simply attach a `@PostHook` decorator to your model class and
|
|
5
5
|
* define the hook function like you normally would in Mongoose.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SchemaTypeOptions } from "mongoose";
|
|
2
|
-
import { MongooseSchemaOptions } from "../interfaces";
|
|
2
|
+
import { MongooseSchemaOptions } from "../interfaces/MongooseSchemaOptions";
|
|
3
3
|
/**
|
|
4
4
|
* Define a class as a Mongoose Schema ready to be used to compose other schemes and models.
|
|
5
5
|
*
|
|
@@ -9,10 +9,6 @@ import { MongooseVirtualRefOptions } from "../interfaces/MongooseVirtualRefOptio
|
|
|
9
9
|
* import in node.
|
|
10
10
|
* :::
|
|
11
11
|
*
|
|
12
|
-
* ### Example
|
|
13
|
-
*
|
|
14
|
-
* <<< @/tutorials/snippets/mongoose/virtual-references.ts
|
|
15
|
-
*
|
|
16
12
|
* @param ref
|
|
17
13
|
* @param foreignField
|
|
18
14
|
* @returns {Function}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,6 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @file Automatically generated by barrelsby.
|
|
3
|
+
*/
|
|
4
4
|
export * from "./MongooseModule";
|
|
5
|
-
export * from "./
|
|
6
|
-
export * from "./decorators";
|
|
5
|
+
export * from "./constants/constants";
|
|
6
|
+
export * from "./decorators/auto";
|
|
7
|
+
export * from "./decorators/discriminatorKey";
|
|
8
|
+
export * from "./decorators/dynamicRef";
|
|
9
|
+
export * from "./decorators/excludeIndexes";
|
|
10
|
+
export * from "./decorators/expires";
|
|
11
|
+
export * from "./decorators/immutable";
|
|
12
|
+
export * from "./decorators/indexed";
|
|
13
|
+
export * from "./decorators/lowercase";
|
|
14
|
+
export * from "./decorators/model";
|
|
15
|
+
export * from "./decorators/mongooseIndex";
|
|
16
|
+
export * from "./decorators/mongooseIndexes";
|
|
17
|
+
export * from "./decorators/mongoosePlugin";
|
|
18
|
+
export * from "./decorators/numberDecimal";
|
|
19
|
+
export * from "./decorators/objectID";
|
|
20
|
+
export * from "./decorators/postHook";
|
|
21
|
+
export * from "./decorators/preHook";
|
|
22
|
+
export * from "./decorators/ref";
|
|
23
|
+
export * from "./decorators/schema";
|
|
24
|
+
export * from "./decorators/schemaIgnore";
|
|
25
|
+
export * from "./decorators/select";
|
|
26
|
+
export * from "./decorators/sparse";
|
|
27
|
+
export * from "./decorators/text";
|
|
28
|
+
export * from "./decorators/trim";
|
|
29
|
+
export * from "./decorators/unique";
|
|
30
|
+
export * from "./decorators/uppercase";
|
|
31
|
+
export * from "./decorators/versionKey";
|
|
32
|
+
export * from "./decorators/virtualRef";
|
|
33
|
+
export * from "./interfaces/MongooseConnectionOptions";
|
|
34
|
+
export * from "./interfaces/MongooseDocument";
|
|
35
|
+
export * from "./interfaces/MongooseModel";
|
|
36
|
+
export * from "./interfaces/MongooseModelOptions";
|
|
37
|
+
export * from "./interfaces/MongooseSchemaOptions";
|
|
38
|
+
export * from "./interfaces/MongooseSchemaTypes";
|
|
39
|
+
export * from "./interfaces/MongooseVirtualRefOptions";
|
|
40
|
+
export * from "./interfaces/interfaces";
|
|
41
|
+
export * from "./registries/MongooseModels";
|
|
42
|
+
export * from "./services/MongooseConnections";
|
|
43
|
+
export * from "./services/MongooseService";
|
|
44
|
+
export * from "./utils/createModel";
|
|
45
|
+
export * from "./utils/createSchema";
|
|
46
|
+
export * from "./utils/resolveRefType";
|
|
47
|
+
export * from "./utils/schemaOptions";
|
|
@@ -5,5 +5,4 @@ export declare type MongooseMergedDocument<T> = {
|
|
|
5
5
|
export interface MongooseDocumentMethods<T> {
|
|
6
6
|
toClass(): T;
|
|
7
7
|
}
|
|
8
|
-
export
|
|
9
|
-
}
|
|
8
|
+
export declare type MongooseModel<T> = Model<MongooseMergedDocument<Document & T & MongooseDocumentMethods<T>>>;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Schema, SchemaOptions } from "mongoose";
|
|
2
2
|
import { MongooseDocument } from "./MongooseDocument";
|
|
3
|
-
export declare type MongooseNextCB = (err?:
|
|
3
|
+
export declare type MongooseNextCB = (err?: Error) => void;
|
|
4
4
|
export interface MongooseHookOptions {
|
|
5
5
|
document?: boolean;
|
|
6
6
|
query?: boolean;
|
|
7
7
|
parallel?: boolean;
|
|
8
8
|
}
|
|
9
9
|
export declare type MongoosePreHookCB<T = any> = ((doc: T | MongooseDocument<T>, next: MongooseNextCB) => void) | ((doc: T | MongooseDocument<T>) => Promise<void> | void);
|
|
10
|
-
export declare type MongoosePostHookCB<T = any> = ((doc: T | MongooseDocument<T>, error:
|
|
10
|
+
export declare type MongoosePostHookCB<T = any> = ((doc: T | MongooseDocument<T>, error: Error, next: MongooseNextCB) => void) | ((doc: T | MongooseDocument<T>, error: Error) => Promise<void> | void) | ((doc: T | MongooseDocument<T>, next: MongooseNextCB) => void) | ((doc: T | MongooseDocument<T>) => Promise<void> | void);
|
|
11
11
|
export interface MongoosePreHook<T = any> {
|
|
12
12
|
method: string | RegExp;
|
|
13
13
|
fn: MongoosePreHookCB<T>;
|
|
@@ -23,7 +23,7 @@ export interface MongoosePluginOptions {
|
|
|
23
23
|
options?: Record<string, unknown>;
|
|
24
24
|
}
|
|
25
25
|
export interface MongooseIndexOptions {
|
|
26
|
-
fields:
|
|
26
|
+
fields: Record<any, any>;
|
|
27
27
|
options?: Record<string, unknown>;
|
|
28
28
|
}
|
|
29
29
|
export interface MongooseSchemaOptions {
|
|
@@ -6,9 +6,3 @@ declare global {
|
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
export * from "./MongooseConnectionOptions";
|
|
10
|
-
export * from "./MongooseDocument";
|
|
11
|
-
export * from "./MongooseModel";
|
|
12
|
-
export * from "./MongooseModelOptions";
|
|
13
|
-
export * from "./MongooseSchemaOptions";
|
|
14
|
-
export * from "./MongooseVirtualRefOptions";
|
|
@@ -11,9 +11,9 @@ export declare function getModelToken(target: Type<any>, options: any): {
|
|
|
11
11
|
* @param {"mongoose".Schema} schema Schema that will be attached to the model.
|
|
12
12
|
* @param name model name
|
|
13
13
|
* @param collection (optional, induced from model name)
|
|
14
|
-
* @param
|
|
14
|
+
* @param overwriteModels
|
|
15
15
|
* @param connection
|
|
16
16
|
* @param discriminatorValue
|
|
17
17
|
* @returns {Model<T extends Document>}
|
|
18
18
|
*/
|
|
19
|
-
export declare function createModel<T>(target: any, schema: mongoose.Schema, name?: string, collection?: string,
|
|
19
|
+
export declare function createModel<T>(target: any, schema: mongoose.Schema, name?: string, collection?: string, overwriteModels?: boolean, connection?: Connection, discriminatorValue?: string): unknown;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Type } from "@tsed/core";
|
|
2
2
|
import { JsonEntityStore } from "@tsed/schema";
|
|
3
3
|
import mongoose, { Schema, SchemaDefinition, SchemaTypeOptions } from "mongoose";
|
|
4
|
-
import { MongooseSchemaOptions } from "../interfaces";
|
|
4
|
+
import { MongooseSchemaOptions } from "../interfaces/MongooseSchemaOptions";
|
|
5
5
|
import { MongooseVirtualRefOptions } from "../interfaces/MongooseVirtualRefOptions";
|
|
6
6
|
export interface MongooseSchemaMetadata {
|
|
7
7
|
schema: SchemaDefinition;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/mongoose",
|
|
3
|
-
"version": "7.0.0-beta.
|
|
3
|
+
"version": "7.0.0-beta.20",
|
|
4
4
|
"description": "Mongoose package for Ts.ED framework",
|
|
5
5
|
"private": false,
|
|
6
6
|
"keywords": [
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
],
|
|
13
13
|
"source": "./src/index.ts",
|
|
14
14
|
"main": "./lib/cjs/index.js",
|
|
15
|
+
"module": "./lib/esm/index.js",
|
|
15
16
|
"typings": "./lib/types/index.d.ts",
|
|
16
17
|
"exports": {
|
|
17
18
|
"types": "./lib/types/index.d.ts",
|
|
@@ -20,38 +21,42 @@
|
|
|
20
21
|
"default": "./lib/esm/index.js"
|
|
21
22
|
},
|
|
22
23
|
"scripts": {
|
|
23
|
-
"build": "yarn run build:esm && yarn run build:cjs",
|
|
24
|
+
"build": "yarn barrels && yarn run build:esm && yarn run build:cjs",
|
|
24
25
|
"build:cjs": "tsc --build tsconfig.compile.json",
|
|
25
26
|
"build:esm": "tsc --build tsconfig.compile.esm.json",
|
|
27
|
+
"barrels": "yarn barrelsby --delete -d ./src -e \"\\.spec\\.ts\" -e \"__mock__\" -e \".benchmark.ts\"",
|
|
26
28
|
"test": "cross-env NODE_ENV=test yarn jest"
|
|
27
29
|
},
|
|
28
30
|
"dependencies": {
|
|
29
31
|
"change-case": "4.1.2",
|
|
30
|
-
"tslib": "2.
|
|
32
|
+
"tslib": "2.4.0"
|
|
31
33
|
},
|
|
32
34
|
"devDependencies": {
|
|
33
|
-
"@tsed/ajv": "7.0.0-beta.
|
|
34
|
-
"@tsed/core": "7.0.0-beta.
|
|
35
|
-
"@tsed/di": "7.0.0-beta.
|
|
36
|
-
"@tsed/json-mapper": "7.0.0-beta.
|
|
37
|
-
"@tsed/logger": "
|
|
38
|
-
"@tsed/schema": "7.0.0-beta.
|
|
39
|
-
"mongoose": "
|
|
35
|
+
"@tsed/ajv": "7.0.0-beta.20",
|
|
36
|
+
"@tsed/core": "7.0.0-beta.20",
|
|
37
|
+
"@tsed/di": "7.0.0-beta.20",
|
|
38
|
+
"@tsed/json-mapper": "7.0.0-beta.20",
|
|
39
|
+
"@tsed/logger": ">=6.2.0",
|
|
40
|
+
"@tsed/schema": "7.0.0-beta.20",
|
|
41
|
+
"mongoose": "6.5.1"
|
|
40
42
|
},
|
|
41
43
|
"peerDependencies": {
|
|
42
|
-
"@tsed/ajv": "^7.0.0-beta.
|
|
43
|
-
"@tsed/core": "^7.0.0-beta.
|
|
44
|
-
"@tsed/di": "^7.0.0-beta.
|
|
45
|
-
"@tsed/json-mapper": "^7.0.0-beta.
|
|
46
|
-
"@tsed/logger": ">=6.
|
|
47
|
-
"@tsed/schema": "^7.0.0-beta.
|
|
48
|
-
"mongoose": ">=
|
|
44
|
+
"@tsed/ajv": "^7.0.0-beta.20",
|
|
45
|
+
"@tsed/core": "^7.0.0-beta.20",
|
|
46
|
+
"@tsed/di": "^7.0.0-beta.20",
|
|
47
|
+
"@tsed/json-mapper": "^7.0.0-beta.20",
|
|
48
|
+
"@tsed/logger": ">=6.2.0",
|
|
49
|
+
"@tsed/schema": "^7.0.0-beta.20",
|
|
50
|
+
"mongoose": ">=6.0.0"
|
|
49
51
|
},
|
|
50
52
|
"repository": "https://github.com/tsedio/tsed",
|
|
51
53
|
"bugs": {
|
|
52
54
|
"url": "https://github.com/tsedio/tsed/issues"
|
|
53
55
|
},
|
|
54
|
-
"homepage": "https://github.com/tsedio/tsed/tree/
|
|
56
|
+
"homepage": "https://github.com/tsedio/tsed/tree/beta/packages/orm/mongoose",
|
|
55
57
|
"author": "Romain Lenzotti",
|
|
56
|
-
"license": "MIT"
|
|
58
|
+
"license": "MIT",
|
|
59
|
+
"publishConfig": {
|
|
60
|
+
"tag": "beta"
|
|
61
|
+
}
|
|
57
62
|
}
|