MCPcopy
hub / github.com/kysely-org/kysely / OnConflictBuilder

Class OnConflictBuilder

src/query-builder/on-conflict-builder.ts:23–273  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21import type { WhereInterface } from './where-interface.js'
22
23export class OnConflictBuilder<
24 DB,
25 TB extends keyof DB,
26> implements WhereInterface<DB, TB> {
27 readonly #props: OnConflictBuilderProps
28
29 constructor(props: OnConflictBuilderProps) {
30 this.#props = freeze(props)
31 }
32
33 /**
34 * Specify a single column as the conflict target.
35 *
36 * Also see the {@link columns}, {@link constraint} and {@link expression}
37 * methods for alternative ways to specify the conflict target.
38 */
39 column(column: AnyColumn<DB, TB>): OnConflictBuilder<DB, TB> {
40 const columnNode = ColumnNode.create(column)
41
42 return new OnConflictBuilder({
43 ...this.#props,
44 onConflictNode: OnConflictNode.cloneWith(this.#props.onConflictNode, {
45 columns: this.#props.onConflictNode.columns
46 ? freeze([...this.#props.onConflictNode.columns, columnNode])
47 : freeze([columnNode]),
48 }),
49 })
50 }
51
52 /**
53 * Specify a list of columns as the conflict target.
54 *
55 * Also see the {@link column}, {@link constraint} and {@link expression}
56 * methods for alternative ways to specify the conflict target.
57 */
58 columns(
59 columns: ReadonlyArray<AnyColumn<DB, TB>>,
60 ): OnConflictBuilder<DB, TB> {
61 const columnNodes = columns.map(ColumnNode.create)
62
63 return new OnConflictBuilder({
64 ...this.#props,
65 onConflictNode: OnConflictNode.cloneWith(this.#props.onConflictNode, {
66 columns: this.#props.onConflictNode.columns
67 ? freeze([...this.#props.onConflictNode.columns, ...columnNodes])
68 : freeze(columnNodes),
69 }),
70 })
71 }
72
73 /**
74 * Specify a specific constraint by name as the conflict target.
75 *
76 * Also see the {@link column}, {@link columns} and {@link expression}
77 * methods for alternative ways to specify the conflict target.
78 */
79 constraint(constraintName: string): OnConflictBuilder<DB, TB> {
80 return new OnConflictBuilder({

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…