Typescript Typings for mysql2.
typings install --save mysql2
or
npm install --save-dev types/mysql2#semver:version
import {createConnection, QueryError, RowDataPacket} from 'mysql2';
const connection = createConnection(process.env['DB']);
connection.query('SELECT 1 + 1 AS solution', (err: QueryError, rows: RowDataPacket[]) => {
console.log('The solution is: ', rows[0]['solution']);
});
connection.execute('UPDATE posts SET title = ? WHERE id = ?', ['Hello World', 1], (err: QueryError, result: OkPacket) => {
console.log(result.affectedRows);
});
You can run them the tests with npm run build
and npm run test
.