test-entity-library-asm 1.3.2 → 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.
@@ -104,7 +104,7 @@ var User = /** @class */ (function () {
104
104
  ], User.prototype, "longitude", void 0);
105
105
  __decorate([
106
106
  (0, typeorm_1.Column)({
107
- length: 20,
107
+ length: 50,
108
108
  comment: 'Contraseña almacenada tipo MD5 del usuario.',
109
109
  }),
110
110
  __metadata("design:type", String)
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/ormconfig.json CHANGED
@@ -1,12 +1,10 @@
1
1
  {
2
- "type": "${DB_TYPE}",
2
+ "type": "mysql",
3
3
  "migrations": [
4
4
  "src/migrations/*.ts"
5
5
  ],
6
6
  "cli": {
7
- "entitiesDir": "src/entities",
8
7
  "migrationsDir": "src/migrations"
9
- },
10
- "driver": "mysql2"
8
+ }
11
9
  }
12
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "test-entity-library-asm",
3
- "version": "1.3.2",
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",
@@ -90,7 +90,7 @@ export class User {
90
90
  longitude: number
91
91
 
92
92
  @Column({
93
- length: 20,
93
+ length: 50,
94
94
  comment: 'Contraseña almacenada tipo MD5 del usuario.',
95
95
  })
96
96
  password: string
package/src/index.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { config } from 'dotenv'
2
2
  import { resolve } from 'path'
3
3
  import { DataSource } from 'typeorm'
4
- import { IShowEntity, IType } from './interfaces'
4
+ import { IType } from './interfaces'
5
5
 
6
6
  let connection: DataSource | null = null
7
7
 
@@ -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
+ }