js database connection
//put these lines in a seperate file
const mysql = require('mysql2');
const connection = mysql.createPool({
host: "localhost",
user: "",
password: "",
database: ""
// here you can set connection limits and so on
});
module.exports = connection;
//put these on destination page
const connection = require('../util/connection');
async function getAll() {
const sql = "SELECT * FROM tableName";
const [rows] = await connection.promise().query(sql);
return rows;
}
exports.getAll = getAll;
Also in JavaScript:
- javascript yield
- js loop ul
- javascript ascending and descending
- react native loading
- function in react
- invoking jquery validator
- close current tab javascript
- using this to get name of the clicked element
- javascript max array
- js code
- node js code for saving first middle and last name
- discord.js send message to specific channel
- javascript detect textarea change
- react native setstate object
- react avatar editor to vuejs
- js conditional key
- get each primary colour and add into an array javascript
- enable version 12 node glitch
- jquery get next element
- js for each item do
- node js find directory change directory
- jquery add class
- implicit return arrow function
- js set visibility