Skip to content

Commit e99533c

Browse files
committed
chore: fix examples
1 parent 90d4e14 commit e99533c

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

documentation/en/TypeScript-Examples.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ In this example, you need to manually check the output types
7373
### Type Specification
7474
#### RowDataPacket[]
7575
An array with the returned rows, for example:
76+
7677
```ts
7778
import mysql, { RowDataPacket } from 'mysql2';
7879

@@ -81,15 +82,15 @@ const conn = mysql.createConnection({
8182
database: 'test',
8283
});
8384

84-
/** SELECT */
85+
// SELECT
8586
conn.query<RowDataPacket[]>('SELECT 1 + 1 AS `test`;', (_err, rows) => {
8687
console.log(rows);
8788
/**
8889
* @rows: [ { test: 2 } ]
8990
*/
9091
});
9192

92-
/** SHOW */
93+
// SHOW
9394
conn.query<RowDataPacket[]>('SHOW TABLES FROM `test`;', (_err, rows) => {
9495
console.log(rows);
9596
/**
@@ -111,18 +112,16 @@ conn.query<RowDataPacket[]>('SHOW TABLES FROM `test`;', (_err, rows) => {
111112
rowsAsArray: true,
112113
});
113114

114-
const sql = `
115-
SELECT 1 + 1 AS test, 2 + 2 AS test;
116-
`;
117-
118-
conn.query<RowDataPacket[][]>(sql, (_err, rows) => {
115+
// SELECT
116+
conn.query<RowDataPacket[][]>('SELECT 1 + 1 AS test, 2 + 2 AS test;', (_err, rows) => {
119117
console.log(rows);
120118
/**
121119
* @rows: [ [ 2, 4 ] ]
122120
*/
123121
});
124122

125-
conn.query<RowDataPacket[][]>(sql, (_err, rows) => {
123+
// SHOW
124+
conn.query<RowDataPacket[][]>('SHOW TABLES FROM `test`;', (_err, rows) => {
126125
console.log(rows);
127126
/**
128127
* @rows: [ [ 'test' ] ]

0 commit comments

Comments
 (0)