Typescript Typings for mysql.
typings install --save mysql
or
npm install --save-dev types/mysql#semver:version
import {createConnection, QueryError, RowDataPacket} from 'mysql';
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.query('UPDATE posts SET title = ? WHERE id = ?', ['Hello World', 1], (err: mysql.QueryError, result: mysql.OkPacket) => {
console.log(result.affectedRows);
});
You can run them the tests with npm run build
and npm run test
.
Based on typings by William Johnston