Replaces mysql with mysql2 library and incorporates connection pooling. The mysql2 library supports using both callbacks and promises from the same connection pool. The mysql2 syntax is mostly compatible with mysql and previous callback code should therefore work while this allows us to incorporate async/await with the db calls going forward.
Any helpful knowledge/context for the reviewer?
The file db.js exports two properties:
module.exports = {
promisePool,
getConnection: () => pool,
};
The promisePool object can be used to call the db with promises and async/await. The getConnection function returns a regular callback compatible pool which works with the current code.
We should conduct fairly extensive testing of this PR since it replaces the DB client library and we want to make sure there are no issues with any of the commands.
What issue is this solving?
Closes #304
Description
Replaces mysql with mysql2 library and incorporates connection pooling. The mysql2 library supports using both callbacks and promises from the same connection pool. The mysql2 syntax is mostly compatible with mysql and previous callback code should therefore work while this allows us to incorporate async/await with the db calls going forward.
Any helpful knowledge/context for the reviewer?
The file db.js exports two properties:
The promisePool object can be used to call the db with promises and async/await. The getConnection function returns a regular callback compatible pool which works with the current code.
We should conduct fairly extensive testing of this PR since it replaces the DB client library and we want to make sure there are no issues with any of the commands.
NPM Library: https://www.npmjs.com/package/mysql2 About promise wrapper: https://github.com/sidorares/node-mysql2#using-promise-wrapper
Please make sure you've attempted to meet the following coding standards