Skip to content

Commit b534e15

Browse files
authored
Merge pull request #342 from szilveszter9/master
split up connection/pool examples
2 parents 7b4f535 + 12860d6 commit b534e15

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

README.md

Lines changed: 8 additions & 3 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();
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');
@@ -105,7 +110,7 @@ var conn = mysql.createConnection({
105110
// continue handshake by sending response data
106111
// respond with error to propagate error to connect/changeUser handlers
107112
cb(null, response);
108-
})
113+
})
109114
}
110115
}
111116
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
},
3939
"devDependencies": {
4040
"assert-diff": "^1.0.1",
41-
"eslint": "^3.0.0",
41+
"eslint": "3.0.0",
4242
"portfinder": "^1.0.3",
4343
"progress": "1.1.8",
4444
"urun": "0.0.8",

0 commit comments

Comments
 (0)