MssqlClient.ts
MssqlClient.ts overview
Section titled “MssqlClient.ts overview”Microsoft SQL Server client implementation for Effect SQL, backed by the
tedious driver.
This module provides the MssqlClient service, constructors, layers, and SQL
Server statement compiler. make creates a pooled Tedious client, checks the
connection with SELECT 1, maps SQL Server failures to SqlError, and
supports transactions with savepoints. The SQL Server-specific service adds
typed Tedious parameters with param, stored procedure calls with call,
direct or config-backed layers, and default parameter type mappings.
Streaming queries are not implemented by this driver.
Since v4.0.0
Exports Grouped by Category
Section titled “Exports Grouped by Category”compiler
Section titled “compiler”makeCompiler
Section titled “makeCompiler”Creates the SQL Server statement compiler, using @1-style placeholders, bracket-escaped identifiers, and SQL Server OUTPUT INSERTED returning clauses.
Signature
declare const makeCompiler: (transform?: (_: string) => string) => Statement.CompilerSince v4.0.0
configuration
Section titled “configuration”defaultParameterTypes
Section titled “defaultParameterTypes”Default mapping from Effect SQL primitive value kinds to Tedious SQL Server parameter data types.
Signature
declare const defaultParameterTypes: Record<Statement.PrimitiveKind, DataType>Since v4.0.0
constructors
Section titled “constructors”Creates a scoped Microsoft SQL Server client backed by a connection pool, with transaction and stored procedure support. Streaming queries are not implemented.
Signature
declare const make: ( options: MssqlClientConfig) => Effect.Effect<MssqlClient, SqlError, Scope.Scope | Reactivity.Reactivity>Since v4.0.0
layers
Section titled “layers”Creates a layer from a concrete SQL Server client configuration, providing both MssqlClient and SqlClient.
Signature
declare const layer: (config: MssqlClientConfig) => Layer.Layer<Client.SqlClient | MssqlClient, never | SqlError>Since v4.0.0
layerConfig
Section titled “layerConfig”Creates a layer from a Config-wrapped SQL Server client configuration, providing both MssqlClient and SqlClient.
Signature
declare const layerConfig: ( config: Config.Wrap<MssqlClientConfig>) => Layer.Layer<Client.SqlClient | MssqlClient, Config.ConfigError | SqlError>Since v4.0.0
models
Section titled “models”MssqlClient (interface)
Section titled “MssqlClient (interface)”Microsoft SQL Server client service, extending SqlClient with typed parameter fragments and stored procedure calls.
Signature
export interface MssqlClient extends Client.SqlClient { readonly [TypeId]: TypeId
readonly config: MssqlClientConfig
readonly param: (type: DataType, value: unknown, options?: ParameterOptions) => Statement.Fragment
readonly call: <I extends Record<string, Parameter<any>>, O extends Record<string, Parameter<any>>, A extends object>( procedure: Procedure.ProcedureWithValues<I, O, A> ) => Effect.Effect<Procedure.Procedure.Result<O, A>, SqlError>}Since v4.0.0
MssqlClientConfig (interface)
Section titled “MssqlClientConfig (interface)”Configuration for a Microsoft SQL Server client, including connection, authentication, pool, parameter type, span attribute, and query/result name transform options.
Signature
export interface MssqlClientConfig { readonly domain?: string | undefined readonly server: string readonly instanceName?: string | undefined readonly encrypt?: boolean | undefined readonly trustServer?: boolean | undefined readonly port?: number | undefined readonly authType?: string | undefined readonly database?: string | undefined readonly username?: string | undefined readonly password?: Redacted.Redacted | undefined readonly connectTimeout?: Duration.Input | undefined readonly cancelTimeout?: Duration.Input | undefined readonly connectionRetryInterval?: Duration.Input | undefined readonly multiSubnetFailover?: boolean | undefined readonly maxRetriesOnTransientErrors?: number | undefined
readonly minConnections?: number | undefined readonly maxConnections?: number | undefined readonly connectionTTL?: Duration.Input | undefined
readonly parameterTypes?: Record<Statement.PrimitiveKind, DataType> | undefined
readonly spanAttributes?: Record<string, unknown> | undefined
readonly transformResultNames?: ((str: string) => string) | undefined readonly transformQueryNames?: ((str: string) => string) | undefined}Since v4.0.0
services
Section titled “services”MssqlClient
Section titled “MssqlClient”Service tag for the Microsoft SQL Server client service.
When to use
Use to access or provide a Microsoft SQL Server client through the Effect context.
Signature
declare const MssqlClient: Context.Service<MssqlClient, MssqlClient>Since v4.0.0
type IDs
Section titled “type IDs”TypeId
Section titled “TypeId”Runtime type identifier used to mark MssqlClient values.
Signature
declare const TypeId: unique symbolSince v4.0.0
TypeId (type alias)
Section titled “TypeId (type alias)”Type-level identifier used to mark MssqlClient values.
Signature
type TypeId = typeof TypeIdSince v4.0.0