Skip to content

Procedure.ts

Typed metadata builders for Microsoft SQL Server stored procedure calls.

This module defines the Procedure values consumed by MssqlClient.call. make starts a procedure definition, param and outputParam add typed Tedious parameter metadata, withRows sets the expected row type, and compile binds input values before execution. The module also defines the typed result shape for output parameters and returned rows.

Since v4.0.0



Binds input values to a SQL Server stored procedure definition, producing a value that can be executed with MssqlClient.call.

Signature

declare const compile: <
I extends Record<string, Parameter.Parameter<any>>,
O extends Record<string, Parameter.Parameter<any>>,
A
>(
self: Procedure<I, O, A>
) => (input: Procedure.ParametersRecord<I>) => ProcedureWithValues<I, O, A>

Source

Since v4.0.0

Adds a typed output parameter to a SQL Server stored procedure definition.

Signature

declare const outputParam: <A>() => <N extends string, T extends DataType>(
name: N,
type: T,
options?: ParameterOptions
) => <I extends Record<string, Parameter.Parameter<any>>, O extends Record<string, Parameter.Parameter<any>>>(
self: Procedure<I, O>
) => Procedure<I, Simplify<O & { [K in N]: Parameter.Parameter<A> }>>

Source

Since v4.0.0

Adds a typed input parameter to a SQL Server stored procedure definition.

Signature

declare const param: <A>() => <N extends string, T extends DataType>(
name: N,
type: T,
options?: ParameterOptions
) => <I extends Record<string, Parameter.Parameter<any>>, O extends Record<string, Parameter.Parameter<any>>>(
self: Procedure<I, O>
) => Procedure<Simplify<I & { [K in N]: Parameter.Parameter<A> }>, O>

Source

Since v4.0.0

Sets the expected row type for a SQL Server stored procedure definition.

Signature

declare const withRows: <A extends object = Row>() => <
I extends Record<string, Parameter.Parameter<any>>,
O extends Record<string, Parameter.Parameter<any>>
>(
self: Procedure<I, O>
) => Procedure<I, O, A>

Source

Since v4.0.0

Creates an empty SQL Server stored procedure definition for the given procedure name.

Signature

declare const make: (name: string) => Procedure<{}, {}>

Source

Since v4.0.0

Pipeable definition of a SQL Server stored procedure, tracking its input parameters, output parameters, and result row type.

Signature

export interface Procedure<
I extends Record<string, Parameter.Parameter<any>>,
O extends Record<string, Parameter.Parameter<any>>,
A = never
> extends Pipeable {
readonly [TypeId]: {
readonly _A: Covariant<A>
}
readonly _tag: "Procedure"
readonly name: string
readonly params: I
readonly outputParams: O
}

Source

Since v4.0.0

Stored procedure definition with concrete input values bound for execution.

Signature

export interface ProcedureWithValues<
I extends Record<string, Parameter.Parameter<any>>,
O extends Record<string, Parameter.Parameter<any>>,
A
> extends Procedure<I, O, A> {
readonly values: Procedure.ParametersRecord<I>
}

Source

Since v4.0.0

Runtime type identifier used to mark SQL Server stored procedure definitions.

Signature

declare const TypeId: "~@effect/sql-mssql/Procedure"

Source

Since v4.0.0

Type-level identifier used to mark SQL Server stored procedure definitions.

Signature

type TypeId = "~@effect/sql-mssql/Procedure"

Source

Since v4.0.0

Namespace containing type helpers and result types for SQL Server stored procedures.

Source

Since v4.0.0

Result of a SQL Server stored procedure call, containing typed output parameter values and returned rows.

Signature

export interface Result<O extends Record<string, Parameter.Parameter<any>>, A> {
readonly output: ParametersRecord<O>
readonly rows: ReadonlyArray<A>
}

Source

Since v4.0.0

Maps a record of Parameter metadata to the corresponding record of parameter value types.

Signature

type { readonly [K in keyof A]: A[K] extends Parameter.Parameter<infer T> ? T : never; } = & {
readonly [K in keyof A]: A[K] extends Parameter.Parameter<infer T> ? T
: never
}
& {}

Source

Since v4.0.0