@@ -106,37 +106,38 @@ conn.query<RowDataPacket[]>('SHOW TABLES FROM `test`;', (_err, rows) => {
106
106
});
107
107
```
108
108
109
- ---
109
+ Using ` rowsAsArray ` option as ` true ` :
110
110
111
- ### RowDataPacket[ ] [ ]
112
- - When ` rowsAsArray ` option is ` true `
113
- ``` ts
114
- import mysql , { RowDataPacket } from ' mysql2' ;
111
+ ``` ts
112
+ import mysql , { RowDataPacket } from ' mysql2' ;
115
113
116
- const conn = mysql .createConnection ({
117
- user: ' test' ,
118
- database: ' test' ,
119
- rowsAsArray: true ,
120
- });
114
+ const conn = mysql .createConnection ({
115
+ user: ' test' ,
116
+ database: ' test' ,
117
+ rowsAsArray: true ,
118
+ });
121
119
122
- // SELECT
123
- conn .query <RowDataPacket [] []>(' SELECT 1 + 1 AS test, 2 + 2 AS test;' , (_err , rows ) => {
124
- console .log (rows );
125
- /**
126
- * @rows: [ [ 2, 4 ] ]
127
- */
128
- });
120
+ // SELECT
121
+ conn .query <RowDataPacket []>(' SELECT 1 + 1 AS test, 2 + 2 AS test;' , (_err , rows ) => {
122
+ console .log (rows );
123
+ /**
124
+ * @rows: [ [ 2, 4 ] ]
125
+ */
126
+ });
129
127
130
- // SHOW
131
- conn .query <RowDataPacket [] []>(' SHOW TABLES FROM `test`;' , (_err , rows ) => {
132
- console .log (rows );
133
- /**
134
- * @rows: [ [ 'test' ] ]
135
- */
136
- });
137
- ```
128
+ // SHOW
129
+ conn .query <RowDataPacket []>(' SHOW TABLES FROM `test`;' , (_err , rows ) => {
130
+ console .log (rows );
131
+ /**
132
+ * @rows: [ [ 'test' ] ]
133
+ */
134
+ });
135
+ ```
138
136
139
- - When ` multipleStatements ` is ` true ` with multiple queries
137
+ ---
138
+
139
+ ### RowDataPacket[ ] [ ]
140
+ Using ` multipleStatements ` option as ` true ` with multiple queries:
140
141
``` ts
141
142
import mysql , { RowDataPacket } from ' mysql2' ;
142
143
@@ -162,7 +163,7 @@ conn.query<RowDataPacket[]>('SHOW TABLES FROM `test`;', (_err, rows) => {
162
163
---
163
164
164
165
### ResultSetHeader
165
- For ` INSERT ` , ` UPDATE ` , ` DELETE ` , ` TRUNCATE ` , etc.
166
+ For ` INSERT ` , ` UPDATE ` , ` DELETE ` , ` TRUNCATE ` , etc.:
166
167
``` ts
167
168
import mysql , { ResultSetHeader } from ' mysql2' ;
168
169
@@ -194,7 +195,7 @@ conn.query<ResultSetHeader>(sql, (_err, result) => {
194
195
---
195
196
196
197
### ResultSetHeader[ ]
197
- For multiples ` INSERT ` , ` UPDATE ` , ` DELETE ` , ` TRUNCATE ` , etc. when using ` multipleStatements ` as ` true `
198
+ For multiples ` INSERT ` , ` UPDATE ` , ` DELETE ` , ` TRUNCATE ` , etc. when using ` multipleStatements ` as ` true ` :
198
199
199
200
``` ts
200
201
import mysql , { ResultSetHeader } from ' mysql2' ;
@@ -240,9 +241,7 @@ conn.query<ResultSetHeader[]>(sql, (_err, results) => {
240
241
---
241
242
242
243
### ProcedureCallPacket
243
- By performing a ** Call Procedure** using ` INSERT ` , ` UPDATE ` , etc., the return will be a ` ProcedureCallPacket<ResultSetHeader> ` (even if you perform multiples queries and set ` multipleStatements ` to ` true ` ).
244
-
245
- > For ` CREATE PROCEDURE ` and ` DROP PROCEDURE ` , these returns will be the * default* ` ResultSetHeader ` .
244
+ By performing a ** Call Procedure** using ` INSERT ` , ` UPDATE ` , etc., the return will be a ` ProcedureCallPacket<ResultSetHeader> ` (even if you perform multiples queries and set ` multipleStatements ` to ` true ` ):
246
245
247
246
``` ts
248
247
import mysql , { ProcedureCallPacket , ResultSetHeader } from ' mysql2' ;
@@ -283,6 +282,8 @@ conn.query<ProcedureCallPacket<ResultSetHeader>>(sql, (_err, result) => {
283
282
});
284
283
```
285
284
285
+ > For ` CREATE PROCEDURE ` and ` DROP PROCEDURE ` , these returns will be the * default* ` ResultSetHeader ` .
286
+
286
287
By using ` SELECT ` and ` SHOW ` queries in a ** Procedure Call** , it groups the results as:
287
288
``` tsx
288
289
// ProcedureCallPacket<RowDataPacket[]>
@@ -291,6 +292,7 @@ By using `SELECT` and `SHOW` queries in a **Procedure Call**, it groups the resu
291
292
// ProcedureCallPacket<RowDataPacket[][]>
292
293
[... RowDataPacket [][], ResultSetHeader ]
293
294
```
295
+
294
296
For ` ProcedureCallPacket<RowDataPacket[]> ` and ` ProcedureCallPacket<RowDataPacket[][]> ` , please see the following examples.
295
297
296
298
---
0 commit comments