Skip to content

Commit 6332315

Browse files
feat(): update to the latest version of mongoose
1 parent 860c56f commit 6332315

File tree

7 files changed

+26
-37
lines changed

7 files changed

+26
-37
lines changed

.eslintrc.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,7 @@ module.exports = {
2121
'@typescript-eslint/explicit-function-return-type': 'off',
2222
'@typescript-eslint/no-explicit-any': 'off',
2323
'@typescript-eslint/no-use-before-define': 'off',
24+
'@typescript-eslint/ban-types': 'off',
25+
'@typescript-eslint/explicit-module-boundary-types': 'off'
2426
},
2527
};

lib/decorators/prop.decorator.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ import { RAW_OBJECT_DEFINITION } from '../mongoose.constants';
44
import { TypeMetadataStorage } from '../storages/type-metadata.storage';
55

66
const TYPE_METADATA_KEY = 'design:type';
7-
87
/**
98
* Interface defining property options that can be passed to `@Prop()` decorator.
109
*/
1110
export type PropOptions =
12-
| mongoose.SchemaTypeOpts<any>
13-
| mongoose.Schema
11+
| mongoose.SchemaDefinition['string']
1412
| mongoose.SchemaType;
1513

1614
/**
@@ -19,7 +17,7 @@ export type PropOptions =
1917
*/
2018
export function Prop(options?: PropOptions): PropertyDecorator {
2119
return (target: object, propertyKey: string | symbol) => {
22-
options = (options || {}) as mongoose.SchemaTypeOpts<unknown>;
20+
options = (options || {}) as mongoose.SchemaTypeOptions<unknown>;
2321

2422
const isRawDefinition = options[RAW_OBJECT_DEFINITION];
2523
if (!options.type && !Array.isArray(options) && !isRawDefinition) {
@@ -40,7 +38,7 @@ export function Prop(options?: PropOptions): PropertyDecorator {
4038
TypeMetadataStorage.addPropertyMetadata({
4139
target: target.constructor,
4240
propertyKey: propertyKey as string,
43-
options,
41+
options: options as PropOptions,
4442
});
4543
};
4644
}

lib/factories/definitions.factory.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ export class DefinitionsFactory {
4141
}
4242

4343
private static inspectTypeDefinition(
44-
optionsOrType: mongoose.SchemaTypeOpts<unknown> | Function,
45-
): PropOptions {
44+
optionsOrType: mongoose.SchemaTypeOptions<unknown> | Function,
45+
): PropOptions | [PropOptions] | Function {
4646
if (typeof optionsOrType === 'function') {
4747
if (this.isPrimitive(optionsOrType)) {
4848
return optionsOrType;
@@ -72,7 +72,7 @@ export class DefinitionsFactory {
7272
} else if (Array.isArray(optionsOrType)) {
7373
return optionsOrType.length > 0
7474
? [this.inspectTypeDefinition(optionsOrType[0])]
75-
: optionsOrType;
75+
: (optionsOrType as any);
7676
}
7777
return optionsOrType;
7878
}

lib/factories/schema.factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export class SchemaFactory {
99
const schemaMetadata = TypeMetadataStorage.getSchemaMetadataByTarget(
1010
target,
1111
);
12-
return new mongoose.Schema<T>(
12+
return new mongoose.Schema(
1313
schemaDefinition,
1414
schemaMetadata && schemaMetadata.options,
1515
);

lib/interfaces/mongoose-options.interface.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Type } from '@nestjs/common';
22
import { ModuleMetadata } from '@nestjs/common/interfaces';
3-
import { ConnectionOptions } from 'mongoose';
3+
import { ConnectOptions } from 'mongoose';
44

55
export interface MongooseModuleOptions
6-
extends ConnectionOptions,
6+
extends ConnectOptions,
77
Record<string, any> {
88
uri?: string;
99
retryAttempts?: number;

package-lock.json

Lines changed: 11 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,11 @@
2222
"devDependencies": {
2323
"@commitlint/cli": "11.0.0",
2424
"@commitlint/config-angular": "11.0.0",
25+
"@nestjs/common": "7.5.5",
26+
"@nestjs/core": "7.5.5",
2527
"@nestjs/platform-express": "7.5.5",
2628
"@nestjs/testing": "7.5.5",
2729
"@types/jest": "26.0.16",
28-
"@nestjs/common": "7.5.5",
29-
"@nestjs/core": "7.5.5",
30-
"@types/mongoose": "5.10.1",
3130
"@types/node": "11.15.0",
3231
"@typescript-eslint/eslint-plugin": "4.9.0",
3332
"@typescript-eslint/parser": "4.9.0",
@@ -37,7 +36,7 @@
3736
"husky": "4.3.0",
3837
"jest": "26.6.3",
3938
"lint-staged": "10.5.2",
40-
"mongoose": "5.10.19",
39+
"mongoose": "^5.11.5",
4140
"prettier": "2.2.1",
4241
"reflect-metadata": "0.1.13",
4342
"release-it": "14.2.2",
@@ -51,8 +50,7 @@
5150
"peerDependencies": {
5251
"@nestjs/common": "^6.0.0 || ^7.0.0",
5352
"@nestjs/core": "^6.0.0 || ^7.0.0",
54-
"@types/mongoose": "^5.0.0",
55-
"mongoose": "^5.4.19",
53+
"mongoose": "^5.11.3",
5654
"reflect-metadata": "^0.1.12",
5755
"rxjs": "^6.0.0"
5856
},

0 commit comments

Comments
 (0)