Hi everyone,
I ran into the following error while attempting to promisify my node.js mysql transactions:
TypeError: this.query is not a function at rollback (/var/task/node_modules/mysql/lib/Connection.js:179:15) at rollback (internal/util.js:230:26)
This took a while to track down but it turns out that I needed to bind the connection after promisifying the function. Instead of:
util.promisify(connection.query);
Add bind to the end of it:
util.promisify(connection.query).bind(connection)
Thanks to the following stackoverflow post for the insight: https://stackoverflow.com/a/51690276/522859