@stashfin/mysql2 1.2.2 → 1.2.3

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/index.d.ts CHANGED
@@ -12,6 +12,6 @@ export declare class MysqlConnector {
12
12
  queryArray<T extends RowDataPacket>(sql: string, values?: Array<string | number>): Promise<T[]>;
13
13
  executeResult(sql: string, values?: unknown[]): Promise<ResultSetHeader>;
14
14
  insertData(tableName: string, data: Record<string, string | number>): Promise<ResultSetHeader>;
15
- updateData(tableName: string, data: Record<string, any>, condition: string): Promise<ResultSetHeader>;
15
+ updateData(tableName: string, data: Record<string, any>, condition: string, conditionValues?: Array<string | number>): Promise<ResultSetHeader>;
16
16
  close(): Promise<void>;
17
17
  }
package/index.js CHANGED
@@ -22,6 +22,7 @@ class MysqlConnector {
22
22
  async queryRow(sql, values) {
23
23
  const connection = await this.getConnection();
24
24
  const [rows] = await connection.query(sql, values);
25
+ await connection.release();
25
26
  return rows[0] || undefined;
26
27
  }
27
28
  async queryRows(sql, values) {
@@ -56,13 +57,14 @@ class MysqlConnector {
56
57
  }
57
58
  async updateData(tableName,
58
59
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
59
- data, condition) {
60
+ data, condition, conditionValues) {
60
61
  const keys = Object.keys(data);
61
62
  const values = Object.values(data);
62
63
  const sql = `UPDATE ${tableName} SET ${keys
63
64
  .map((key) => `${key} = ?`)
64
65
  .join(', ')} WHERE ${condition}`;
65
- return this.executeResult(sql, values);
66
+ const finalValues = [...values, ...(conditionValues || [])];
67
+ return this.executeResult(sql, finalValues);
66
68
  }
67
69
  async close() {
68
70
  await this.pool.end();
@@ -6,41 +6,46 @@ export type JSONObject = {
6
6
  };
7
7
  export type JSONArray = Array<JSONValue>;
8
8
  export interface CustomerTable {
9
- id?: number;
9
+ id: number;
10
10
  mobile: string;
11
- email?: string;
12
- firstName?: string;
13
- middleName?: string;
14
- lastName?: string;
15
- fatherName?: string;
16
- motherMaidenName?: string;
17
- dob?: string;
18
- companyName?: string;
19
- pincode?: string;
20
- mpin?: string;
21
- pan?: string;
22
- aadhaar?: string;
23
- mobileVerified?: boolean;
24
- emailVerified?: boolean;
25
- ip?: string;
26
- deviceId?: string;
27
- osVersion?: string;
28
- pushId?: string;
29
- authToken?: string;
30
- appVersion?: string;
31
- biometricEnabled?: boolean;
32
- journeyStep?: number;
33
- category?: string;
34
- locLimit?: number;
35
- status?: 'active' | 'inactive';
36
- source?: string;
37
- tncVersion?: string;
38
- loginDate?: string;
39
- agentId?: number;
40
- createdAt?: string;
41
- updatedAt?: string;
42
- isActive?: boolean;
43
- isDeleted?: boolean;
11
+ email?: string | null;
12
+ first_name?: string | null;
13
+ middle_name?: string | null;
14
+ last_name?: string | null;
15
+ father_name?: string | null;
16
+ mother_maiden_name?: string | null;
17
+ dob?: Date | null;
18
+ company_name?: string | null;
19
+ pincode?: string | null;
20
+ mpin?: string | null;
21
+ pan?: string | null;
22
+ aadhaar?: string | null;
23
+ mobile_verified?: number | null;
24
+ email_verified?: number | null;
25
+ ip?: string | null;
26
+ device_id?: string | null;
27
+ os_version?: string | null;
28
+ push_id?: string | null;
29
+ auth_token?: string | null;
30
+ app_version?: string | null;
31
+ biometric_enabled?: number | null;
32
+ journey_step?: number | null;
33
+ category?: string | null;
34
+ loc_limit?: number | null;
35
+ /** Defaults to: active. */
36
+ status?: 'active' | 'inactive' | null;
37
+ source?: string | null;
38
+ tnc_version?: string | null;
39
+ login_date?: Date | null;
40
+ agent_id?: number | null;
41
+ /** Defaults to: CURRENT_TIMESTAMP. */
42
+ created_at?: Date | null;
43
+ /** Defaults to: CURRENT_TIMESTAMP. */
44
+ updated_at?: Date | null;
45
+ /** Defaults to: 1. */
46
+ is_active?: number | null;
47
+ /** Defaults to: 0. */
48
+ is_deleted?: number | null;
44
49
  }
45
50
  export interface DemographicsTable {
46
51
  id?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stashfin/mysql2",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",