SqlClient overview
Added in v1.0.0
Table of contents
constructors
make
Signature
export declare const make: (options: SqlClient.MakeOptions) => Effect<SqlClient, never, Reactivity>
Added in v1.0.0
models
SqlClient
Signature
export declare const SqlClient: Tag<SqlClient, SqlClient>
Added in v1.0.0
SqlClient (interface)
Signature
export interface SqlClient extends Constructor {
readonly [TypeId]: TypeId
/**
* Copy of the client for safeql etc.
*/
readonly safe: this
/**
* Copy of the client without transformations.
*/
readonly withoutTransforms: () => this
readonly reserve: Effect<Connection, SqlError, Scope>
/**
* With the given effect, ensure all sql queries are run in a transaction.
*/
readonly withTransaction: <R, E, A>(self: Effect<A, E, R>) => Effect<A, E | SqlError, R>
/**
* Use the Reactivity service from @effect/experimental to create a reactive
* query.
*/
readonly reactive: <A, E, R>(
keys: ReadonlyArray<unknown> | ReadonlyRecord<string, ReadonlyArray<unknown>>,
effect: Effect<A, E, R>
) => Stream<A, E, R>
/**
* Use the Reactivity service from @effect/experimental to create a reactive
* query.
*/
readonly reactiveMailbox: <A, E, R>(
keys: ReadonlyArray<unknown> | ReadonlyRecord<string, ReadonlyArray<unknown>>,
effect: Effect<A, E, R>
) => Effect<ReadonlyMailbox<A, E>, never, R | Scope>
}
Added in v1.0.0
SqlClient (namespace)
Added in v1.0.0
MakeOptions (interface)
Signature
export interface MakeOptions {
readonly acquirer: Connection.Acquirer
readonly compiler: Compiler
readonly transactionAcquirer?: Connection.Acquirer
readonly spanAttributes: ReadonlyArray<readonly [string, unknown]>
readonly beginTransaction?: string | undefined
readonly rollback?: string | undefined
readonly commit?: string | undefined
readonly savepoint?: ((name: string) => string) | undefined
readonly rollbackSavepoint?: ((name: string) => string) | undefined
readonly transformRows?: (<A extends object>(row: ReadonlyArray<A>) => ReadonlyArray<A>) | undefined
readonly reactiveMailbox?: <A, E, R>(
keys: ReadonlyArray<unknown> | ReadonlyRecord<string, ReadonlyArray<unknown>>,
effect: Effect<A, E, R>
) => Effect<ReadonlyMailbox<A, E>, never, R | Scope>
}
Added in v1.0.0
transactions
makeWithTransaction
Signature
export declare const makeWithTransaction: <I, S>(options: {
readonly transactionTag: Tag<I, readonly [conn: S, counter: number]>
readonly spanAttributes: ReadonlyArray<readonly [string, unknown]>
readonly acquireConnection: Effect<readonly [CloseableScope | undefined, S], SqlError>
readonly begin: (conn: NoInfer<S>) => Effect<void, SqlError>
readonly savepoint: (conn: NoInfer<S>, id: number) => Effect<void, SqlError>
readonly commit: (conn: NoInfer<S>) => Effect<void, SqlError>
readonly rollback: (conn: NoInfer<S>) => Effect<void, SqlError>
readonly rollbackSavepoint: (conn: NoInfer<S>, id: number) => Effect<void, SqlError>
}) => <R, E, A>(effect: Effect<A, E, R>) => Effect<A, E | SqlError, R>
Added in v1.0.0
type ids
TypeId
Signature
export declare const TypeId: typeof TypeId
Added in v1.0.0
TypeId (type alias)
Signature
export type TypeId = typeof TypeId
Added in v1.0.0
utils
TransactionConnection
Signature
export declare const TransactionConnection: Tag<TransactionConnection, readonly [conn: Connection, depth: number]>
Added in v1.0.0
TransactionConnection (interface)
Signature
export interface TransactionConnection {
readonly _: unique symbol
}
Added in v1.0.0