@stashfin/mysql2 1.3.0 → 1.4.1

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, string | number>, 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) {
@@ -54,13 +55,16 @@ class MysqlConnector {
54
55
  .join(', ')})`;
55
56
  return this.executeResult(sql, values);
56
57
  }
57
- async updateData(tableName, data, condition) {
58
+ async updateData(tableName,
59
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
60
+ data, condition, conditionValues) {
58
61
  const keys = Object.keys(data);
59
62
  const values = Object.values(data);
60
63
  const sql = `UPDATE ${tableName} SET ${keys
61
64
  .map((key) => `${key} = ?`)
62
65
  .join(', ')} WHERE ${condition}`;
63
- return this.executeResult(sql, values);
66
+ const finalValues = [...values, ...(conditionValues || [])];
67
+ return this.executeResult(sql, finalValues);
64
68
  }
65
69
  async close() {
66
70
  await this.pool.end();
@@ -1,65 +1,95 @@
1
1
  import { RowDataPacket } from 'mysql2';
2
+ export type JSONPrimitive = string | number | boolean | null;
3
+ export type JSONValue = JSONObject | JSONArray;
4
+ export type JSONObject = {
5
+ [member: string]: JSONPrimitive;
6
+ };
7
+ export type JSONArray = Array<JSONValue>;
2
8
  export interface CustomerTable {
3
- id?: number;
9
+ id: number;
4
10
  mobile: string;
5
- email?: string;
6
- firstName?: string;
7
- middleName?: string;
8
- lastName?: string;
9
- fatherName?: string;
10
- motherMaidenName?: string;
11
- dob?: string;
12
- companyName?: string;
13
- pincode?: string;
14
- mpin?: string;
15
- pan?: string;
16
- aadhaar?: string;
17
- mobileVerified?: boolean;
18
- emailVerified?: boolean;
19
- ip?: string;
20
- deviceId?: string;
21
- osVersion?: string;
22
- pushId?: string;
23
- authToken?: string;
24
- appVersion?: string;
25
- biometricEnabled?: boolean;
26
- journeyStep?: number;
27
- category?: string;
28
- locLimit?: number;
29
- status?: 'active' | 'inactive';
30
- source?: string;
31
- tncVersion?: string;
32
- loginDate?: string;
33
- agentId?: number;
34
- createdAt?: string;
35
- updatedAt?: string;
36
- isActive?: boolean;
37
- 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;
38
49
  }
39
50
  export interface DemographicsTable {
40
51
  id?: number;
41
- customerId: number;
42
- aadhaarName?: string;
43
- salary?: number;
44
- salaryDate?: string;
45
- salaryMode?: string;
46
- gender?: string;
47
- maritalStatus?: string;
48
- occupation?: string;
49
- photo?: string;
50
- gstNo?: string;
51
- crn?: string;
52
- organizationId?: number;
53
- latitude?: number;
54
- longitude?: number;
55
- language?: string;
56
- residentialAddr?: object;
57
- officeAddr?: object;
58
- device?: object;
59
- createdAt?: string;
60
- updatedAt?: string;
52
+ customer_id: number;
53
+ aadhaar_name?: string | null;
54
+ crn?: string | null;
55
+ device?: JSONValue | null;
56
+ gender?: string | null;
57
+ gst_no?: string | null;
58
+ language?: string | null;
59
+ latitude?: number | null;
60
+ longitude?: number | null;
61
+ marital_status?: string | null;
62
+ occupation?: string | null;
63
+ office_addr?: JSONValue | null;
64
+ organization_id?: number | null;
65
+ pan_url?: string | null;
66
+ perm_addr?: JSONValue | null;
67
+ res_addr?: JSONValue | null;
68
+ salary?: number | null;
69
+ salary_date?: Date | null;
70
+ salary_mode?: string | null;
71
+ selfie_url?: string | null;
72
+ /** Defaults to: CURRENT_TIMESTAMP. */
73
+ created_at?: Date | null;
74
+ updated_at?: Date | null;
75
+ }
76
+ export interface CustomerBanksTable {
77
+ id?: number;
78
+ customer_id: number;
79
+ account_number: string;
80
+ address?: string | null;
81
+ bank_name?: string | null;
82
+ ifsc_code?: string | null;
83
+ /** Defaults to: active. */
84
+ status?: 'active' | 'inactive';
85
+ is_primary?: boolean;
86
+ /** Defaults to: CURRENT_TIMESTAMP. */
87
+ created_at?: Date | null;
88
+ updated_at?: Date | null;
61
89
  }
62
90
  export interface CustomerModel extends CustomerTable, RowDataPacket {
63
91
  }
92
+ export interface CustomerBanksModel extends CustomerBanksTable, RowDataPacket {
93
+ }
64
94
  export interface DemographicsModel extends DemographicsTable, RowDataPacket {
65
95
  }
@@ -0,0 +1,38 @@
1
+ import { RowDataPacket } from "mysql2";
2
+ interface Rule {
3
+ key: string;
4
+ value: string | number;
5
+ operator: string;
6
+ }
7
+ interface Rules {
8
+ data: Rule[];
9
+ }
10
+ export interface OfferTable {
11
+ id: bigint;
12
+ title: string;
13
+ reward_type: string;
14
+ amount: number;
15
+ discount_type: string;
16
+ max_value: number;
17
+ rpu: number;
18
+ budget: number;
19
+ icon: string;
20
+ event_name: string;
21
+ description: string;
22
+ validity: number;
23
+ redirect_url: string;
24
+ offer_type: string;
25
+ start_required: boolean;
26
+ is_active: boolean;
27
+ deleted: boolean;
28
+ csv_segment: number;
29
+ expiry: string;
30
+ rules: Rules;
31
+ stats: string;
32
+ created_at: string;
33
+ updated_at: string;
34
+ created_by: string;
35
+ }
36
+ export interface OfferModel extends OfferTable, RowDataPacket {
37
+ }
38
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -7,5 +7,5 @@ export interface UserAuthTokenTable {
7
7
  published: number;
8
8
  device_id: string;
9
9
  }
10
- export interface UserAuthTokenModel extends UserAuthTokenTable, RowDataPacket {
10
+ export interface UserAuthTokenModel extends RowDataPacket {
11
11
  }
@@ -1,6 +1,6 @@
1
1
  import { RowDataPacket } from 'mysql2';
2
2
  export interface UserDetailTable {
3
- id: number;
3
+ id: string;
4
4
  first_name: string;
5
5
  middle_name: string;
6
6
  last_name: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stashfin/mysql2",
3
- "version": "1.3.0",
3
+ "version": "1.4.1",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",