From d93ace5f1fe2f84abe4cb22f84ad8b63f28eeac4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20My=C5=9Bliwiec?= Date: Thu, 7 Jan 2021 10:12:07 +0100 Subject: [PATCH] fix(): return a typed schema from create for class method --- lib/factories/schema.factory.ts | 6 +++-- package-lock.json | 42 ++++++++++++++++----------------- package.json | 2 +- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/lib/factories/schema.factory.ts b/lib/factories/schema.factory.ts index 60509c16..caedd15c 100644 --- a/lib/factories/schema.factory.ts +++ b/lib/factories/schema.factory.ts @@ -4,12 +4,14 @@ import { TypeMetadataStorage } from '../storages/type-metadata.storage'; import { DefinitionsFactory } from './definitions.factory'; export class SchemaFactory { - static createForClass(target: Type) { + static createForClass = any>( + target: T, + ): mongoose.Schema>> { const schemaDefinition = DefinitionsFactory.createForClass(target); const schemaMetadata = TypeMetadataStorage.getSchemaMetadataByTarget( target, ); - return new mongoose.Schema( + return new mongoose.Schema>>( schemaDefinition, schemaMetadata && schemaMetadata.options, ); diff --git a/package-lock.json b/package-lock.json index 9f979357..cd498546 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2258,9 +2258,9 @@ "dev": true }, "@types/mongodb": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/@types/mongodb/-/mongodb-3.6.2.tgz", - "integrity": "sha512-bPr+qfixiWW4N3JSOOq9NiK2HOIvZajp9ebthhVMpBhzrH3x1noBohyzBB+sA+xRkIg7okp3upDV4eyO+jg2Yw==", + "version": "3.6.3", + "resolved": "https://registry.npmjs.org/@types/mongodb/-/mongodb-3.6.3.tgz", + "integrity": "sha512-6YNqGP1hk5bjUFaim+QoFFuI61WjHiHE1BNeB41TA00Xd2K7zG4lcWyLLq/XtIp36uMavvS5hoAUJ+1u/GcX2Q==", "dev": true, "requires": { "@types/bson": "*", @@ -3877,9 +3877,9 @@ "dev": true }, "denque": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/denque/-/denque-1.4.1.tgz", - "integrity": "sha512-OfzPuSZKGcgr96rf1oODnfjqBFmr1DVoc/TrItj3Ohe0Ah1C5WX5Baquw/9U9KovnQ88EqmJbD66rKYUQYN1tQ==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/denque/-/denque-1.5.0.tgz", + "integrity": "sha512-CYiCSgIF1p6EUByQPlGkKnP1M9g0ZV3qMIrqMqZqdwazygIA/YP2vrbcyl1h/WppKJTdl1F85cXIle+394iDAQ==", "dev": true }, "depd": { @@ -8689,9 +8689,9 @@ } }, "kareem": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/kareem/-/kareem-2.3.1.tgz", - "integrity": "sha512-l3hLhffs9zqoDe8zjmb/mAN4B8VT3L56EUvKNqLFVs9YlFA+zx7ke1DO8STAdDyYNkeSo1nKmjuvQeI12So8Xw==", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/kareem/-/kareem-2.3.2.tgz", + "integrity": "sha512-STHz9P7X2L4Kwn72fA4rGyqyXdmrMSdxqHx9IXon/FXluXieaFA6KJ2upcHAHxQPQ0LeM/OjLrhFxifHewOALQ==", "dev": true }, "keyv": { @@ -9410,18 +9410,18 @@ } }, "mongoose": { - "version": "5.11.5", - "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.11.5.tgz", - "integrity": "sha512-uwSeALQ1+qamUZBrIe1D6/uCzlHvcSbNQPG9w02DJqF3VHJSFOX1RdoxJE/wTN6WW7tTV8NMdLDSdxKqfo8J1A==", + "version": "5.11.10", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.11.10.tgz", + "integrity": "sha512-daE2L6VW7WNywv7tL2KUkBViWvODbzr50Of1kJpIbzW3w3N5/TYcgSmhCsEDWfYGQXbun2rdd7+sOdsEC8zQSQ==", "dev": true, "requires": { "@types/mongodb": "^3.5.27", "bson": "^1.1.4", - "kareem": "2.3.1", + "kareem": "2.3.2", "mongodb": "3.6.3", "mongoose-legacy-pluralize": "1.0.2", - "mpath": "0.8.0", - "mquery": "3.2.2", + "mpath": "0.8.3", + "mquery": "3.2.3", "ms": "2.1.2", "regexp-clone": "1.0.0", "safe-buffer": "5.2.1", @@ -9444,15 +9444,15 @@ "dev": true }, "mpath": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/mpath/-/mpath-0.8.0.tgz", - "integrity": "sha512-slIifXzF6pBxKpPV47ScgqWfGgkpwZNy55fY/umDrgmAxjWMz/WYzYsd8cThU49kw0rLyPWTZaWrOlazaeW57Q==", + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/mpath/-/mpath-0.8.3.tgz", + "integrity": "sha512-eb9rRvhDltXVNL6Fxd2zM9D4vKBxjVVQNLNijlj7uoXUy19zNDsIif5zR+pWmPCWNKwAtqyo4JveQm4nfD5+eA==", "dev": true }, "mquery": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/mquery/-/mquery-3.2.2.tgz", - "integrity": "sha512-XB52992COp0KP230I3qloVUbkLUxJIu328HBP2t2EsxSFtf4W1HPSOBWOXf1bqxK4Xbb66lfMJ+Bpfd9/yZE1Q==", + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/mquery/-/mquery-3.2.3.tgz", + "integrity": "sha512-cIfbP4TyMYX+SkaQ2MntD+F2XbqaBHUYWk3j+kqdDztPWok3tgyssOZxMHMtzbV1w9DaSlvEea0Iocuro41A4g==", "dev": true, "requires": { "bluebird": "3.5.1", diff --git a/package.json b/package.json index 0c120d0e..a2ecd73b 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "husky": "4.3.5", "jest": "26.6.3", "lint-staged": "10.5.3", - "mongoose": "5.11.5", + "mongoose": "^5.11.10", "prettier": "2.2.1", "reflect-metadata": "0.1.13", "release-it": "14.2.2",