A simple way to manage connections to multiple SQL Server databases using the Node.js Tedious driver.
npm install @cityssm/mssql-multi-poolsh
npm install @cityssm/mssql-multi-pool
`
๐ก If you want to use msnodesqlv8, it must be installed separately.
Usage
Replace the connect(config) command from the mssql package
with the connect(config) command from the @cityssm/mssql-multi-pool package.
If the configuration object describes an unseen database, a new pool is made.
Otherwise, the previously made pool is used.
`typescript
import mssqlMultiPool, { type mssql } from '@cityssm/mssql-multi-pool'
const pool = await mssqlMultiPool.connect(config)
// Use the mssql package like before.
const results = (await pool
.request()
.input('workOrderNumber', '2024-01234')
.query(
'select * from WorkOrders where workOrderNumber = @workOrderNumber'
)) as mssql.IResult
``