@vetrivelan-cp/mongoose 1.0.0

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.
@@ -0,0 +1 @@
1
+ export declare const InjectModel: (modelName: string) => PropertyDecorator & ParameterDecorator;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InjectModel = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ const get_model_token_1 = require("../utils/get-model-token");
6
+ const InjectModel = (modelName) => (0, common_1.Inject)((0, get_model_token_1.getModelToken)(modelName));
7
+ exports.InjectModel = InjectModel;
8
+ //# sourceMappingURL=inject-model.decorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inject-model.decorator.js","sourceRoot":"","sources":["../../src/decorators/inject-model.decorator.ts"],"names":[],"mappings":";;;AACA,2CAAwC;AACxC,8DAAyD;AAElD,MAAM,WAAW,GAAG,CAAC,SAAiB,EAAE,EAAE,CAC/C,IAAA,eAAM,EAAC,IAAA,+BAAa,EAAC,SAAS,CAAC,CAAC,CAAC;AADtB,QAAA,WAAW,eACW"}
@@ -0,0 +1,3 @@
1
+ export * from './mongoose.module';
2
+ export * from './decorators/inject-model.decorator';
3
+ export * from './utils/get-model-token';
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./mongoose.module"), exports);
18
+ __exportStar(require("./decorators/inject-model.decorator"), exports);
19
+ __exportStar(require("./utils/get-model-token"), exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,oDAAkC;AAClC,sEAAoD;AACpD,0DAAwC"}
@@ -0,0 +1,4 @@
1
+ import { DynamicModule } from '@nestjs/common';
2
+ export declare class CpMongooseModule {
3
+ static forFeature(models: any[]): DynamicModule;
4
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var CpMongooseModule_1;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.CpMongooseModule = void 0;
11
+ const common_1 = require("@nestjs/common");
12
+ const get_model_token_1 = require("./utils/get-model-token");
13
+ let CpMongooseModule = CpMongooseModule_1 = class CpMongooseModule {
14
+ static forFeature(models) {
15
+ const providers = models.map((model) => ({
16
+ provide: (0, get_model_token_1.getModelToken)(model.name),
17
+ useFactory: (connection) => connection.model(model.name, model.schema),
18
+ inject: ['DATABASE_CONNECTION'],
19
+ }));
20
+ return {
21
+ module: CpMongooseModule_1,
22
+ providers,
23
+ exports: providers,
24
+ };
25
+ }
26
+ };
27
+ exports.CpMongooseModule = CpMongooseModule;
28
+ exports.CpMongooseModule = CpMongooseModule = CpMongooseModule_1 = __decorate([
29
+ (0, common_1.Module)({})
30
+ ], CpMongooseModule);
31
+ //# sourceMappingURL=mongoose.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mongoose.module.js","sourceRoot":"","sources":["../src/mongoose.module.ts"],"names":[],"mappings":";;;;;;;;;;AACA,2CAAuD;AAEvD,6DAAwD;AAGjD,IAAM,gBAAgB,wBAAtB,MAAM,gBAAgB;IAC3B,MAAM,CAAC,UAAU,CAAC,MAAa;QAC7B,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YACvC,OAAO,EAAE,IAAA,+BAAa,EAAC,KAAK,CAAC,IAAI,CAAC;YAClC,UAAU,EAAE,CAAC,UAAsB,EAAE,EAAE,CACrC,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC;YAC5C,MAAM,EAAE,CAAC,qBAAqB,CAAC;SAChC,CAAC,CAAC,CAAC;QAEJ,OAAO;YACL,MAAM,EAAE,kBAAgB;YACxB,SAAS;YACT,OAAO,EAAE,SAAS;SACnB,CAAC;IACJ,CAAC;CACF,CAAA;AAfY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,gBAAgB,CAe5B"}
@@ -0,0 +1 @@
1
+ export declare const getModelToken: (modelName: string) => string;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getModelToken = void 0;
4
+ const getModelToken = (modelName) => {
5
+ return `${modelName}Model`;
6
+ };
7
+ exports.getModelToken = getModelToken;
8
+ //# sourceMappingURL=get-model-token.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-model-token.js","sourceRoot":"","sources":["../../src/utils/get-model-token.ts"],"names":[],"mappings":";;;AACO,MAAM,aAAa,GAAG,CAAC,SAAiB,EAAU,EAAE;IACzD,OAAO,GAAG,SAAS,OAAO,CAAC;AAC7B,CAAC,CAAC;AAFW,QAAA,aAAa,iBAExB"}
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@vetrivelan-cp/mongoose",
3
+ "version": "1.0.0",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "scripts": {
10
+ "build": "rimraf dist && tsc",
11
+ "prepublishOnly": "npm run build"
12
+ },
13
+ "author": "vetrivelan",
14
+ "license": "ISC",
15
+ "peerDependencies": {
16
+ "@nestjs/common": "^10.0.0 || ^11.0.0",
17
+ "@nestjs/core": "^10.0.0 || ^11.0.0",
18
+ "mongoose": "^8.0.0"
19
+ },
20
+ "devDependencies": {
21
+ "@types/node": "^22.13.0",
22
+ "rimraf": "^5.0.10",
23
+ "typescript": "^5.9.3"
24
+ }
25
+ }