Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing Pool Promise #41

Open
aollag09 opened this issue Apr 7, 2020 · 1 comment
Open

Missing Pool Promise #41

aollag09 opened this issue Apr 7, 2020 · 1 comment

Comments

@aollag09
Copy link

aollag09 commented Apr 7, 2020

Hi there,

The function promise() is not available on the Pool class :( !?
Thanks for your help !

@OssiPesonen
Copy link

OssiPesonen commented Jun 19, 2022

Tad late to the party here, but here's how I solved my types.

import * as mysql from 'mysql2';
import { Connection, Pool } from 'mysql2';

export const createConnectionPool = (): Pool => {
  return mysql.createPool(databaseConfig);
}

// When called I cast it as Connection because Pool extends it
const pool = config.createConnectionPool() as Connection;
const db = pool.promise();

Now the Connection type for db is from mysql2/promise

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants