types / mysql2

Typings for https://github.com/sidorares/node-mysql2
ISC License
41 stars 23 forks source link

Fix to Promise CreateConnection #18

Closed worbunkel closed 6 years ago

worbunkel commented 6 years ago

This is an adjustment to the promise create connection type. It should return a Promise. This change is based on the node-mysql2 docs and source:

async function main() {
  // get the client
  const  mysql = require('mysql2/promise');
  // create the connection
  const connection = await mysql.createConnection({host:'localhost', user: 'root', database: 'test'});
  // query database
  const [rows, fields] = await connection.execute('SELECT * FROM `table` WHERE `name` = ? AND `age` > ?', ['Morty', 14]);
}

I wasn't able to run the tests, but I adjusted them anyway. Let me know if anything doesn't work and I'll update the PR.

felixfbecker commented 6 years ago

The tests are not designed to be run, they test TypeScript regressions in the usage.

worbunkel commented 6 years ago

@felixfbecker That makes sense. Updated the PR based on review.