@zintrust/db-mysql 0.1.20 → 0.1.21

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
@@ -12,6 +12,7 @@ export type DatabaseConfig = {
12
12
  export type QueryResult = {
13
13
  rows: Record<string, unknown>[];
14
14
  rowCount: number;
15
+ lastInsertId?: string | number | bigint;
15
16
  };
16
17
  export interface IDatabaseAdapter {
17
18
  connect(): Promise<void>;
package/dist/index.js CHANGED
@@ -46,7 +46,13 @@ function normalizeQueryResult(raw) {
46
46
  const affectedRows = typeof maybe.affectedRows === 'number' && Number.isFinite(maybe.affectedRows)
47
47
  ? maybe.affectedRows
48
48
  : 0;
49
- return { rows: [], rowCount: affectedRows };
49
+ const insertId = (typeof maybe.insertId === 'number' ||
50
+ typeof maybe.insertId === 'string' ||
51
+ typeof maybe.insertId === 'bigint') &&
52
+ maybe.insertId !== 0 // Only return if valid ID
53
+ ? maybe.insertId
54
+ : undefined;
55
+ return { rows: [], rowCount: affectedRows, lastInsertId: insertId };
50
56
  }
51
57
  return { rows: [], rowCount: 0 };
52
58
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zintrust/db-mysql",
3
- "version": "0.1.20",
3
+ "version": "0.1.21",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -22,7 +22,7 @@
22
22
  "node": ">=20.0.0"
23
23
  },
24
24
  "peerDependencies": {
25
- "@zintrust/core": "^0.1.20"
25
+ "@zintrust/core": "^0.1.21"
26
26
  },
27
27
  "publishConfig": {
28
28
  "access": "public"