@nestjs/mongoose
Advanced tools
Comparing version 7.2.3 to 7.2.4
@@ -14,9 +14,10 @@ "use strict"; | ||
const mongoose_utils_1 = require("./common/mongoose.utils"); | ||
function addDiscriminators(model, discriminators = []) { | ||
discriminators.forEach(({ name, schema }) => model.discriminator(name, schema)); | ||
} | ||
function createMongooseProviders(connectionName, options = []) { | ||
return options.reduce((providers, option) => [ | ||
...providers, | ||
...createMongooseProviders(connectionName, option.discriminators), | ||
...(option.discriminators || []).map((d) => ({ | ||
provide: mongoose_utils_1.getModelToken(d.name), | ||
useFactory: (model) => model.discriminator(d.name, d.schema), | ||
inject: [mongoose_utils_1.getModelToken(option.name)], | ||
})), | ||
{ | ||
@@ -26,3 +27,2 @@ provide: mongoose_utils_1.getModelToken(option.name), | ||
const model = connection.model(option.name, option.schema, option.collection); | ||
addDiscriminators(model, option.discriminators); | ||
return model; | ||
@@ -44,3 +44,2 @@ }, | ||
const model = connection.model(option.name, schema, option.collection); | ||
addDiscriminators(model, option.discriminators); | ||
return model; | ||
@@ -50,3 +49,7 @@ }), | ||
}, | ||
...createMongooseAsyncProviders(connectionName, (option.discriminators || []).map(({ name, schema }) => ({ name, useFactory: () => __awaiter(this, void 0, void 0, function* () { return schema; }) }))), | ||
...(option.discriminators || []).map((d) => ({ | ||
provide: mongoose_utils_1.getModelToken(d.name), | ||
useFactory: (model) => model.discriminator(d.name, d.schema), | ||
inject: [mongoose_utils_1.getModelToken(option.name)], | ||
})), | ||
]; | ||
@@ -53,0 +56,0 @@ }, []); |
{ | ||
"name": "@nestjs/mongoose", | ||
"version": "7.2.3", | ||
"version": "7.2.4", | ||
"description": "Nest - modern, fast, powerful node.js web framework (@mongoose)", | ||
@@ -23,28 +23,28 @@ "author": "Kamil Mysliwiec", | ||
"devDependencies": { | ||
"@commitlint/cli": "11.0.0", | ||
"@commitlint/config-angular": "11.0.0", | ||
"@nestjs/common": "7.6.11", | ||
"@nestjs/core": "7.6.11", | ||
"@nestjs/platform-express": "7.6.11", | ||
"@nestjs/testing": "7.6.11", | ||
"@commitlint/cli": "12.0.0", | ||
"@commitlint/config-angular": "12.0.0", | ||
"@nestjs/common": "7.6.13", | ||
"@nestjs/core": "7.6.13", | ||
"@nestjs/platform-express": "7.6.13", | ||
"@nestjs/testing": "7.6.13", | ||
"@types/jest": "26.0.20", | ||
"@types/node": "14.14.25", | ||
"@typescript-eslint/eslint-plugin": "4.14.2", | ||
"@typescript-eslint/parser": "4.14.2", | ||
"eslint": "7.19.0", | ||
"eslint-config-prettier": "7.2.0", | ||
"@types/node": "14.14.31", | ||
"@typescript-eslint/eslint-plugin": "4.15.2", | ||
"@typescript-eslint/parser": "4.15.2", | ||
"eslint": "7.20.0", | ||
"eslint-config-prettier": "8.1.0", | ||
"eslint-plugin-import": "2.22.1", | ||
"husky": "4.3.8", | ||
"husky": "5.1.1", | ||
"jest": "26.6.3", | ||
"lint-staged": "10.5.3", | ||
"mongoose": "5.11.15", | ||
"lint-staged": "10.5.4", | ||
"mongoose": "5.11.18", | ||
"prettier": "2.2.1", | ||
"reflect-metadata": "0.1.13", | ||
"release-it": "14.3.0", | ||
"rxjs": "6.6.3", | ||
"rxjs-compat": "6.6.3", | ||
"release-it": "14.4.1", | ||
"rxjs": "6.6.6", | ||
"rxjs-compat": "6.6.6", | ||
"supertest": "6.1.3", | ||
"ts-jest": "26.5.0", | ||
"ts-jest": "26.5.2", | ||
"ts-node": "9.1.1", | ||
"typescript": "4.1.3" | ||
"typescript": "4.2.2" | ||
}, | ||
@@ -51,0 +51,0 @@ "peerDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1332
75322