Overview
MS SQL Server dialect that uses the tedious library for database communication and tarn.js for connection pooling. Source:src/dialect/mssql/mssql-dialect.ts:52
Installation
Install the required peer dependencies:Basic Usage
Configuration
MssqlDialectConfig
Source:src/dialect/mssql/mssql-dialect-config.ts:3
The
tedious package configuration including the connection factory.You need to pass the tedious package itself along with a factory function that creates new Connection instances.The
tarn package configuration for connection pooling.You need to pass the tarn package itself along with pool options (excluding create, destroy, and validate functions which are controlled by this dialect).At minimum, you must specify min and max connection counts.When
true, connections are validated before being acquired from the pool, resulting in additional requests to the database.This helps ensure that connections are still alive before use, but adds overhead.When
true, connections are reset to their initial states when released back to the pool, resulting in additional requests to the database.This ensures clean connection state but adds overhead on every connection release.Connection Configuration
The tedious Connection accepts many configuration options:Pool Configuration
Configure the tarn.js connection pool:Authentication Methods
SQL Server Authentication
Windows Authentication
Azure Active Directory Password
Azure Active Directory Service Principal
SSL/TLS Configuration
For secure connections:Azure SQL Database
Configuration for Azure SQL Database:Connection Validation
Control when connections are validated:Setting
validateConnections to true adds a small overhead but helps catch broken connections before they’re used. Setting resetConnectionsOnRelease to true ensures clean state but adds more overhead.Transactions and Isolation Levels
Set transaction isolation levels:read uncommittedread committedrepeatable readserializablesnapshot
Related Types
Tedious
Source:src/dialect/mssql/mssql-dialect-config.ts:78
Tarn
Source:src/dialect/mssql/mssql-dialect-config.ts:178
TarnPoolOptions
Source:src/dialect/mssql/mssql-dialect-config.ts:204
TediousConnection
Source:src/dialect/mssql/mssql-dialect-config.ts:90
The tedious Connection interface with methods for executing queries and managing transactions.
TediousTypes
Source:src/dialect/mssql/mssql-dialect-config.ts:158
Type definitions for SQL Server data types: