gimm285-api-project/server/model/connection.js

19 lines
353 B
JavaScript
Raw Normal View History

2023-04-18 14:41:16 -06:00
const mysql = require('mysql2/promise');
const credentials = require('./creds.json');
let connection = null;
async function query(sql, params) {
if (null === connection) {
connection = await mysql.createConnection(credentials);
}
const [results, ] = await connection.execute(sql, params);
return results;
}
module.exports = {
query
}