Closed tomsaleeba closed 7 years ago
Alternatively you can also close the connection after the query is done but then you can't use that same connection further down the chain. Might not suit everyone.
'use strict'
var mysql = require('promise-mysql');
mysql.createConnection({
host: process.env.DBURL,
port: process.env.DBPORT,
user: process.env.DBUSER,
password: process.env.DBPASS,
database: process.env.DBNAME
}).then(function(conn){
let result = conn.query('select 1;')
conn.end()
return result
}).then(function(rows){
console.log(rows)
})
Thanks for letting me know! If you want to make a PR to update the docs then go ahead, otherwise I'll try and update it myself we at some point.
On Wed, 24 May 2017, 07:10 Tom Saleeba, notifications@github.com wrote:
Alternatively you can also close the connection after the query is done but then you can't use that same connection further down the chain. Might not suit everyone.
'use strict' var mysql = require('promise-mysql');
mysql.createConnection({ host: process.env.DBURL, port: process.env.DBPORT, user: process.env.DBUSER, password: process.env.DBPASS, database: process.env.DBNAME }).then(function(conn){ let result = conn.query('select 1;') conn.end() return result }).then(function(rows){ console.log(rows) })
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/lukeb-uk/node-promise-mysql/issues/51#issuecomment-303619283, or mute the thread https://github.com/notifications/unsubscribe-auth/AEjy1BOgsKfaS2kJLjd3xuqzwOj3amC0ks5r87u1gaJpZM4NkmnO .
PR created :+1:
Fixed in #52
Steps:
mysql.createConnection({ host: process.env.DBURL, port: process.env.DBPORT, user: process.env.DBUSER, password: process.env.DBPASS, database: process.env.DBNAME }).then(function(conn){ connection = conn return connection.query('select 1;') }).then(function(rows){ //connection.end() // doco example doesn't show calling end() console.log(rows) })