File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -36,8 +36,9 @@ In addition to errback interface there is thin wrapper to expose Promise-based a
36
36
mysql .createConnection ({ /* same parameters as for non-promise createConnection */ })
37
37
.then ((conn ) => conn .query (' select foo from bar' ))
38
38
.then (([rows , fields ]) => console .log (rows[0 ].foo ))
39
+ ```
39
40
40
- // pool:
41
+ ``` js
41
42
var pool = require (' mysql2/promise' ).createPool ({}); // or mysql.createPoolPromise({})
42
43
pool .getConnection ()
43
44
.then ((conn ) => {
@@ -57,7 +58,11 @@ es7 async/await:
57
58
let mysql = require (' mysql2/promise' );
58
59
let conn = await mysql .createConnection ({ database: test });
59
60
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 });
61
66
// execute in parallel, next console.log in 3 seconds
62
67
await Promise .all ([pool .query (' select sleep(2)' ), pool .query (' select sleep(3)' )]);
63
68
console .log (' 3 seconds after' );
@@ -105,7 +110,7 @@ var conn = mysql.createConnection({
105
110
// continue handshake by sending response data
106
111
// respond with error to propagate error to connect/changeUser handlers
107
112
cb (null , response);
108
- })
113
+ })
109
114
}
110
115
}
111
116
});
Original file line number Diff line number Diff line change 38
38
},
39
39
"devDependencies" : {
40
40
"assert-diff" : " ^1.0.1" ,
41
- "eslint" : " ^ 3.0.0" ,
41
+ "eslint" : " 3.0.0" ,
42
42
"portfinder" : " ^1.0.3" ,
43
43
"progress" : " 1.1.8" ,
44
44
"urun" : " 0.0.8" ,
You can’t perform that action at this time.
0 commit comments