Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const mysql = require('whatever-mysql-lib');
- let pool = null;
- const getConnection() {
- if (pool === null) {
- pool = mysql.createPool({
- connectionLimit: 10,
- host: 'localhost',
- user: 'root',
- password: '<snip>',
- database: 'purchases'
- });
- }
- return pool.getConnection();
- };
- const query(query) {
- let connection = getConnection();
- return connection.query(query);
- }
- module.exports = {
- query: query,
- getConnection: getConnection
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement