Statement overview
Added in v1.0.0
Table of contents
- compiler
- constructor
- guard
- model
- Argument (type alias)
- ArrayHelper (interface)
- Compiler (interface)
- Constructor (interface)
- Custom (interface)
- Fragment (interface)
- Helper (type alias)
- Identifier (interface)
- Literal (interface)
- Parameter (interface)
- Primitive (type alias)
- PrimitiveKind (type alias)
- RecordInsertHelper (interface)
- RecordUpdateHelper (interface)
- RecordUpdateHelperSingle (interface)
- Segment (type alias)
- Statement (interface)
- type id
- utils
compiler
makeCompiler
Signature
export declare const makeCompiler: <C extends Custom<any, any, any, any> = any>(
parameterPlaceholder: (index: number) => string,
onIdentifier: (value: string) => string,
onRecordUpdate: (
placeholders: string,
alias: string,
columns: string,
values: ReadonlyArray<ReadonlyArray<Primitive>>
) => readonly [sql: string, params: ReadonlyArray<Primitive>],
onCustom: (type: C, placeholder: () => string) => readonly [sql: string, params: ReadonlyArray<Primitive>],
onInsert?:
| ((
columns: ReadonlyArray<string>,
placeholders: string,
values: ReadonlyArray<ReadonlyArray<Primitive>>
) => readonly [sql: string, binds: ReadonlyArray<Primitive>])
| undefined,
onRecordUpdateSingle?:
| ((
columns: ReadonlyArray<string>,
values: ReadonlyArray<Primitive>
) => readonly [sql: string, params: ReadonlyArray<Primitive>])
| undefined
) => Compiler
Added in v1.0.0
constructor
and
Signature
export declare const and: (clauses: ReadonlyArray<string | Fragment>) => Fragment
Added in v1.0.0
csv
Signature
export declare const csv: {
(values: ReadonlyArray<string | Fragment>): Fragment
(prefix: string, values: ReadonlyArray<string | Fragment>): Fragment
}
Added in v1.0.0
custom
Signature
export declare const custom: <C extends Custom<any, any, any, any>>(
kind: C["kind"]
) => (i0: C["i0"], i1: C["i1"], i2: C["i2"]) => Fragment
Added in v1.0.0
join
Signature
export declare const join: (
literal: string,
addParens?: boolean,
fallback?: string
) => (clauses: ReadonlyArray<string | Fragment>) => Fragment
Added in v1.0.0
make
Signature
export declare const make: (acquirer: Connection.Acquirer, compiler: Compiler) => Constructor
Added in v1.0.0
or
Signature
export declare const or: (clauses: ReadonlyArray<string | Fragment>) => Fragment
Added in v1.0.0
unsafe
Signature
export declare const unsafe: (
acquirer: Connection.Acquirer,
compiler: Compiler
) => <A extends object = Row>(sql: string, params?: ReadonlyArray<Primitive> | undefined) => Statement<A>
Added in v1.0.0
unsafeFragment
Signature
export declare const unsafeFragment: (sql: string, params?: ReadonlyArray<Primitive> | undefined) => Fragment
Added in v1.0.0
guard
isCustom
Signature
export declare const isCustom: <A extends Custom<any, any, any, any>>(kind: A["kind"]) => (u: unknown) => u is A
Added in v1.0.0
isFragment
Signature
export declare const isFragment: (u: unknown) => u is Fragment
Added in v1.0.0
model
Argument (type alias)
Signature
export type Argument = Primitive | Helper | Fragment
Added in v1.0.0
ArrayHelper (interface)
Signature
export interface ArrayHelper {
readonly _tag: "ArrayHelper"
readonly value: ReadonlyArray<Primitive | Fragment>
}
Added in v1.0.0
Compiler (interface)
Signature
export interface Compiler {
readonly compile: (statement: Fragment) => readonly [sql: string, params: ReadonlyArray<Primitive>]
}
Added in v1.0.0
Constructor (interface)
Signature
export interface Constructor {
<A extends object = Row>(strings: TemplateStringsArray, ...args: Array<Argument>): Statement<A>
(value: string): Identifier
(value: ReadonlyArray<Primitive | Record<string, Primitive | Fragment>>): ArrayHelper
readonly insert: {
(value: ReadonlyArray<Record<string, Primitive | Fragment>>): RecordInsertHelper
(value: Record<string, Primitive | Fragment>): RecordInsertHelper
}
readonly update: <A extends Record<string, Primitive | Fragment>>(
value: A,
omit?: ReadonlyArray<keyof A>
) => RecordUpdateHelperSingle
readonly updateValues: (
value: ReadonlyArray<Record<string, Primitive | Fragment>>,
alias: string
) => RecordUpdateHelper
}
Added in v1.0.0
Custom (interface)
Signature
export interface Custom<T extends string = string, A = void, B = void, C = void> {
readonly _tag: "Custom"
readonly kind: T
readonly i0: A
readonly i1: B
readonly i2: C
}
Added in v1.0.0
Fragment (interface)
Signature
export interface Fragment {
readonly [FragmentId]: (_: never) => FragmentId
readonly segments: ReadonlyArray<Segment>
}
Added in v1.0.0
Helper (type alias)
Signature
export type Helper =
| ArrayHelper
| RecordInsertHelper
| RecordUpdateHelper
| RecordUpdateHelperSingle
| Identifier
| Custom
Added in v1.0.0
Identifier (interface)
Signature
export interface Identifier {
readonly _tag: "Identifier"
readonly value: string
}
Added in v1.0.0
Literal (interface)
Signature
export interface Literal {
readonly _tag: "Literal"
readonly value: string
readonly params?: ReadonlyArray<Primitive> | undefined
}
Added in v1.0.0
Parameter (interface)
Signature
export interface Parameter {
readonly _tag: "Parameter"
readonly value: Primitive
}
Added in v1.0.0
Primitive (type alias)
Signature
export type Primitive = string | number | bigint | boolean | Date | null | Int8Array | Uint8Array
Added in v1.0.0
PrimitiveKind (type alias)
Signature
export type PrimitiveKind = "string" | "number" | "bigint" | "boolean" | "Date" | "null" | "Int8Array" | "Uint8Array"
Added in v1.0.0
RecordInsertHelper (interface)
Signature
export interface RecordInsertHelper {
readonly _tag: "RecordInsertHelper"
readonly value: ReadonlyArray<Record<string, Primitive | Fragment>>
}
Added in v1.0.0
RecordUpdateHelper (interface)
Signature
export interface RecordUpdateHelper {
readonly _tag: "RecordUpdateHelper"
readonly value: ReadonlyArray<Record<string, Primitive | Fragment>>
readonly alias: string
}
Added in v1.0.0
RecordUpdateHelperSingle (interface)
Signature
export interface RecordUpdateHelperSingle {
readonly _tag: "RecordUpdateHelperSingle"
readonly value: Record<string, Primitive | Fragment>
readonly omit: ReadonlyArray<string>
}
Added in v1.0.0
Segment (type alias)
Signature
export type Segment =
| Literal
| Identifier
| Parameter
| ArrayHelper
| RecordInsertHelper
| RecordUpdateHelper
| RecordUpdateHelperSingle
| Custom
Added in v1.0.0
Statement (interface)
Signature
export interface Statement<A> extends Fragment, Effect<ReadonlyArray<A>, SqlError>, Pipeable {
readonly withoutTransform: Effect<ReadonlyArray<A>, SqlError>
readonly stream: Stream.Stream<A, SqlError>
readonly values: Effect<ReadonlyArray<ReadonlyArray<Primitive>>, SqlError>
readonly compile: () => readonly [sql: string, params: ReadonlyArray<Primitive>]
}
Added in v1.0.0
type id
FragmentId
Signature
export declare const FragmentId: typeof FragmentId
Added in v1.0.0
FragmentId (type alias)
Signature
export type FragmentId = typeof FragmentId
Added in v1.0.0
utils
defaultEscape
Signature
export declare const defaultEscape: (c: string) => (str: string) => string
Added in v1.0.0
primitiveKind
Signature
export declare const primitiveKind: (value: Primitive) => PrimitiveKind
Added in v1.0.0