test-entity-library-asm 1.3.3 → 1.3.4

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/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  import { DataSource } from 'typeorm';
2
2
  export declare function createDataBaseSource(): DataSource;
3
3
  export declare function showEntity(entityName: string): Promise<any>;
4
+ export declare function callStoredProcedure(storedProcedure: string): Promise<any>;
package/dist/index.js CHANGED
@@ -36,7 +36,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
36
  }
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.showEntity = exports.createDataBaseSource = void 0;
39
+ exports.callStoredProcedure = exports.showEntity = exports.createDataBaseSource = void 0;
40
40
  var dotenv_1 = require("dotenv");
41
41
  var path_1 = require("path");
42
42
  var typeorm_1 = require("typeorm");
@@ -87,3 +87,21 @@ function showEntity(entityName) {
87
87
  });
88
88
  }
89
89
  exports.showEntity = showEntity;
90
+ function callStoredProcedure(storedProcedure) {
91
+ return __awaiter(this, void 0, void 0, function () {
92
+ return __generator(this, function (_a) {
93
+ switch (_a.label) {
94
+ case 0:
95
+ if (!!connection) return [3 /*break*/, 2];
96
+ connection = createDataBaseSource();
97
+ return [4 /*yield*/, connection.initialize()];
98
+ case 1:
99
+ _a.sent();
100
+ _a.label = 2;
101
+ case 2: return [4 /*yield*/, connection.query("CALL ".concat(storedProcedure))];
102
+ case 3: return [2 /*return*/, _a.sent()];
103
+ }
104
+ });
105
+ });
106
+ }
107
+ exports.callStoredProcedure = callStoredProcedure;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "test-entity-library-asm",
3
- "version": "1.3.3",
3
+ "version": "1.3.4",
4
4
  "description": "Entidades de ejemplo para una base de datos",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -43,3 +43,12 @@ export async function showEntity(entityName: string): Promise<any> {
43
43
 
44
44
  return connection.getRepository(entityName)
45
45
  }
46
+
47
+ export async function callStoredProcedure(storedProcedure: string) {
48
+ if (!connection) {
49
+ connection = createDataBaseSource()
50
+ await connection.initialize()
51
+ }
52
+
53
+ return await connection.query(`CALL ${storedProcedure}`)
54
+ }