badmfck-api-server 1.1.1 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
@@ -2,6 +2,7 @@ import { FieldInfo, MysqlError, Pool, PoolConnection } from "mysql";
|
|
2
2
|
import { BaseService } from "./BaseService";
|
3
3
|
import { Req } from "badmfck-signal";
|
4
4
|
export declare const REQ_MYSQL_QUERY: Req<MySqlQuery | MySqlQuery[], MysqlResult[]>;
|
5
|
+
export declare const executeQuery: (query: MySqlQuery | MySqlQuery[]) => Promise<MysqlResult[]>;
|
5
6
|
export interface MysqlServiceOptions {
|
6
7
|
connectionLimit: number;
|
7
8
|
host: string;
|
@@ -37,6 +38,7 @@ export declare class MysqlService extends BaseService {
|
|
37
38
|
options: MysqlServiceOptions;
|
38
39
|
retries: number;
|
39
40
|
constructor(options: MysqlServiceOptions);
|
41
|
+
static executeQuery(query: MySqlQuery | MySqlQuery[]): Promise<MysqlResult[]>;
|
40
42
|
init(): Promise<void>;
|
41
43
|
onApplicationReady(): Promise<void>;
|
42
44
|
static prepareQuery(query: string, fields: MysqlQueryField[]): string;
|
@@ -3,11 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.MysqlService = exports.REQ_MYSQL_QUERY = void 0;
|
6
|
+
exports.MysqlService = exports.executeQuery = exports.REQ_MYSQL_QUERY = void 0;
|
7
7
|
const mysql_1 = __importDefault(require("mysql"));
|
8
8
|
const BaseService_1 = require("./BaseService");
|
9
9
|
const badmfck_signal_1 = require("badmfck-signal");
|
10
10
|
exports.REQ_MYSQL_QUERY = new badmfck_signal_1.Req();
|
11
|
+
const executeQuery = async (query) => { return await exports.REQ_MYSQL_QUERY.request(query); };
|
12
|
+
exports.executeQuery = executeQuery;
|
11
13
|
class MysqlService extends BaseService_1.BaseService {
|
12
14
|
reconnectionTimeout = 1000 * 3;
|
13
15
|
reconnecting = false;
|
@@ -19,6 +21,7 @@ class MysqlService extends BaseService_1.BaseService {
|
|
19
21
|
this.options = options;
|
20
22
|
this.init();
|
21
23
|
}
|
24
|
+
static async executeQuery(query) { return await exports.REQ_MYSQL_QUERY.request(query); }
|
22
25
|
async init() {
|
23
26
|
const ok = await this.createPool();
|
24
27
|
if (!ok) {
|