UNPKG

rbt_mssql-pool-party

Version:

Extension of mssql that provides management of multiple connection pools, dsns, retries, and more

24 lines (22 loc) 657 B
import sql from 'mssql'; export default function defaultConnectionPoolFactory(dsn) { const connection = new sql.ConnectionPool(dsn); // we don't want an 'Uncaught, unspecified "error" event.' exception // so we have a dummy listener here. connection.on('error', () => {}); return connection.connect() .then( // a pool is an object that has dsn and connection properties () => ({ connection, dsn, }), // even if we fail to connect, we still want to create the pool, so we // can attempt to heal it later on (err) => ({ connection, dsn, error: err, }), ); }