Optional
resetThis dialect uses the tarn
package to manage the connection pool to your
database. To use it as a peer dependency and not bundle it with Kysely's code,
you need to pass the tarn
package itself. You also need to pass some pool options
(excluding create
, destroy
and validate
functions which are controlled by this dialect),
min
& max
connections at the very least.
import { MssqlDialect } from 'kysely'
import * as Tarn from 'tarn'
import * as Tedious from 'tedious'
const dialect = new MssqlDialect({
tarn: { ...Tarn, options: { max: 10, min: 0 } },
tedious: {
...Tedious,
connectionFactory: () => new Tedious.Connection({
// ...
server: 'localhost',
// ...
}),
}
})
This dialect uses the tedious
package to communicate with your MS SQL Server
database. To use it as a peer dependency and not bundle it with Kysely's code,
you need to pass the tedious
package itself. You also need to pass a factory
function that creates new tedious
Connection
instances on demand.
import { MssqlDialect } from 'kysely'
import * as Tarn from 'tarn'
import * as Tedious from 'tedious'
const dialect = new MssqlDialect({
tarn: { ...Tarn, options: { max: 10, min: 0 } },
tedious: {
...Tedious,
connectionFactory: () => new Tedious.Connection({
// ...
server: 'localhost',
// ...
}),
}
})
Optional
validateWhen true
, connections are validated before being acquired from the pool,
resulting in additional requests to the database.
Defaults to true
.
When
true
, connections are reset to their initial states when released back to the pool, resulting in additional requests to the database.Defaults to
false
.