Skip to content

Commit 849a295

Browse files
committed
👕 split up connection/pool examples
1 parent ab7fc05 commit 849a295

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ In addition to errback interface there is thin wrapper to expose Promise-based a
3636
mysql.createConnection({ /* same parameters as for non-promise createConnection */ })
3737
.then((conn) => conn.query('select foo from bar'))
3838
.then(([rows, fields]) => console.log(rows[0].foo))
39+
```
3940

40-
// pool:
41+
```js
4142
var pool = require('mysql2/promise').createPool({}); // or mysql.createPoolPromise({})
4243
pool.getConnection()
4344
.then((conn) => {
@@ -57,7 +58,11 @@ es7 async/await:
5758
let mysql = require('mysql2/promise');
5859
let conn = await mysql.createConnection({ database: test });
5960
let [rows, fields] = await conn.execute('select ?+? as sum', [2, 2]);
60-
let pool = mysql.createPool(conn);
61+
```
62+
63+
```js
64+
let mysql = require('mysql2/promise');
65+
let pool = mysql.createPool({ database: test });
6166
// execute in parallel, next console.log in 3 seconds
6267
await Promise.all([pool.query('select sleep(2)'), pool.query('select sleep(3)')]);
6368
console.log('3 seconds after');

0 commit comments

Comments
 (0)