/
opt
/
canhelp
/
node_modules
/
kysely
/
dist
/
esm
/
query-builder
/
/opt/canhelp/node_modules/kysely/dist/esm/query-builder
mkdir
upload
Name
Size
Mode
Actions
aggregate-function-builder.d.ts
13602
0644
edit
dl
rm
aggregate-function-builder.js
7666
0644
edit
dl
rm
case-builder.d.ts
6689
0644
edit
dl
rm
case-builder.js
2563
0644
edit
dl
rm
cte-builder.d.ts
802
0644
edit
dl
rm
cte-builder.js
961
0644
edit
dl
rm
delete-query-builder.d.ts
47443
0644
edit
dl
rm
delete-query-builder.js
15843
0644
edit
dl
rm
delete-result.d.ts
116
0644
edit
dl
rm
delete-result.js
183
0644
edit
dl
rm
function-module.d.ts
23521
0644
edit
dl
rm
function-module.js
2299
0644
edit
dl
rm
having-interface.d.ts
953
0644
edit
dl
rm
having-interface.js
61
0644
edit
dl
rm
insert-query-builder.d.ts
40215
0644
edit
dl
rm
insert-query-builder.js
35726
0644
edit
dl
rm
insert-result.d.ts
1735
0644
edit
dl
rm
insert-result.js
1783
0644
edit
dl
rm
join-builder.d.ts
1773
0644
edit
dl
rm
join-builder.js
1583
0644
edit
dl
rm
json-path-builder.d.ts
9545
0644
edit
dl
rm
json-path-builder.js
5817
0644
edit
dl
rm
merge-query-builder.d.ts
37025
0644
edit
dl
rm
merge-query-builder.js
20065
0644
edit
dl
rm
merge-result.d.ts
139
0644
edit
dl
rm
merge-result.js
181
0644
edit
dl
rm
no-result-error.d.ts
478
0644
edit
dl
rm
no-result-error.js
384
0644
edit
dl
rm
on-conflict-builder.d.ts
25573
0644
edit
dl
rm
on-conflict-builder.js
8116
0644
edit
dl
rm
order-by-interface.d.ts
4883
0644
edit
dl
rm
order-by-interface.js
63
0644
edit
dl
rm
order-by-item-builder.d.ts
1372
0644
edit
dl
rm
order-by-item-builder.js
2132
0644
edit
dl
rm
output-interface.d.ts
5477
0644
edit
dl
rm
output-interface.js
61
0644
edit
dl
rm
over-builder.d.ts
3755
0644
edit
dl
rm
over-builder.js
1239
0644
edit
dl
rm
returning-interface.d.ts
3496
0644
edit
dl
rm
returning-interface.js
64
0644
edit
dl
rm
select-query-builder-expression.d.ts
962
0644
edit
dl
rm
select-query-builder-expression.js
76
0644
edit
dl
rm
select-query-builder.d.ts
78467
0644
edit
dl
rm
select-query-builder.js
13062
0644
edit
dl
rm
update-query-builder.d.ts
50254
0644
edit
dl
rm
update-query-builder.js
16441
0644
edit
dl
rm
update-result.d.ts
497
0644
edit
dl
rm
update-result.js
572
0644
edit
dl
rm
where-interface.d.ts
10814
0644
edit
dl
rm
where-interface.js
60
0644
edit
dl
rm
Edit:
/opt/canhelp/node_modules/kysely/dist/esm/query-builder/on-conflict-builder.js
(8116B)
/// <reference types="./on-conflict-builder.d.ts" /> import { ColumnNode } from '../operation-node/column-node.js'; import { IdentifierNode } from '../operation-node/identifier-node.js'; import { OnConflictNode } from '../operation-node/on-conflict-node.js'; import { parseValueBinaryOperationOrExpression, parseReferentialBinaryOperation, } from '../parser/binary-operation-parser.js'; import { parseUpdateObjectExpression, } from '../parser/update-set-parser.js'; import { freeze } from '../util/object-utils.js'; export class OnConflictBuilder { #props; constructor(props) { this.#props = freeze(props); } /** * Specify a single column as the conflict target. * * Also see the {@link columns}, {@link constraint} and {@link expression} * methods for alternative ways to specify the conflict target. */ column(column) { const columnNode = ColumnNode.create(column); return new OnConflictBuilder({ ...this.#props, onConflictNode: OnConflictNode.cloneWith(this.#props.onConflictNode, { columns: this.#props.onConflictNode.columns ? freeze([...this.#props.onConflictNode.columns, columnNode]) : freeze([columnNode]), }), }); } /** * Specify a list of columns as the conflict target. * * Also see the {@link column}, {@link constraint} and {@link expression} * methods for alternative ways to specify the conflict target. */ columns(columns) { const columnNodes = columns.map(ColumnNode.create); return new OnConflictBuilder({ ...this.#props, onConflictNode: OnConflictNode.cloneWith(this.#props.onConflictNode, { columns: this.#props.onConflictNode.columns ? freeze([...this.#props.onConflictNode.columns, ...columnNodes]) : freeze(columnNodes), }), }); } /** * Specify a specific constraint by name as the conflict target. * * Also see the {@link column}, {@link columns} and {@link expression} * methods for alternative ways to specify the conflict target. */ constraint(constraintName) { return new OnConflictBuilder({ ...this.#props, onConflictNode: OnConflictNode.cloneWith(this.#props.onConflictNode, { constraint: IdentifierNode.create(constraintName), }), }); } /** * Specify an expression as the conflict target. * * This can be used if the unique index is an expression index. * * Also see the {@link column}, {@link columns} and {@link constraint} * methods for alternative ways to specify the conflict target. */ expression(expression) { return new OnConflictBuilder({ ...this.#props, onConflictNode: OnConflictNode.cloneWith(this.#props.onConflictNode, { indexExpression: expression.toOperationNode(), }), }); } where(...args) { return new OnConflictBuilder({ ...this.#props, onConflictNode: OnConflictNode.cloneWithIndexWhere(this.#props.onConflictNode, parseValueBinaryOperationOrExpression(args)), }); } whereRef(lhs, op, rhs) { return new OnConflictBuilder({ ...this.#props, onConflictNode: OnConflictNode.cloneWithIndexWhere(this.#props.onConflictNode, parseReferentialBinaryOperation(lhs, op, rhs)), }); } clearWhere() { return new OnConflictBuilder({ ...this.#props, onConflictNode: OnConflictNode.cloneWithoutIndexWhere(this.#props.onConflictNode), }); } /** * Adds the "do nothing" conflict action. * * ### Examples * * ```ts * const id = 1 * const first_name = 'John' * * await db * .insertInto('person') * .values({ first_name, id }) * .onConflict((oc) => oc * .column('id') * .doNothing() * ) * .execute() * ``` * * The generated SQL (PostgreSQL): * * ```sql * insert into "person" ("first_name", "id") * values ($1, $2) * on conflict ("id") do nothing * ``` */ doNothing() { return new OnConflictDoNothingBuilder({ ...this.#props, onConflictNode: OnConflictNode.cloneWith(this.#props.onConflictNode, { doNothing: true, }), }); } /** * Adds the "do update set" conflict action. * * ### Examples * * ```ts * const id = 1 * const first_name = 'John' * * await db * .insertInto('person') * .values({ first_name, id }) * .onConflict((oc) => oc * .column('id') * .doUpdateSet({ first_name }) * ) * .execute() * ``` * * The generated SQL (PostgreSQL): * * ```sql * insert into "person" ("first_name", "id") * values ($1, $2) * on conflict ("id") * do update set "first_name" = $3 * ``` * * In the next example we use the `ref` method to reference * columns of the virtual table `excluded` in a type-safe way * to create an upsert operation: * * ```ts * import type { NewPerson } from 'type-editor' // imaginary module * * async function upsertPerson(person: NewPerson): Promise<void> { * await db.insertInto('person') * .values(person) * .onConflict((oc) => oc * .column('id') * .doUpdateSet((eb) => ({ * first_name: eb.ref('excluded.first_name'), * last_name: eb.ref('excluded.last_name') * }) * ) * ) * .execute() * } * ``` * * The generated SQL (PostgreSQL): * * ```sql * insert into "person" ("first_name", "last_name") * values ($1, $2) * on conflict ("id") * do update set * "first_name" = excluded."first_name", * "last_name" = excluded."last_name" * ``` */ doUpdateSet(update) { return new OnConflictUpdateBuilder({ ...this.#props, onConflictNode: OnConflictNode.cloneWith(this.#props.onConflictNode, { updates: parseUpdateObjectExpression(update), }), }); } /** * Simply calls the provided function passing `this` as the only argument. `$call` returns * what the provided function returns. */ $call(func) { return func(this); } } export class OnConflictDoNothingBuilder { #props; constructor(props) { this.#props = freeze(props); } toOperationNode() { return this.#props.onConflictNode; } } export class OnConflictUpdateBuilder { #props; constructor(props) { this.#props = freeze(props); } where(...args) { return new OnConflictUpdateBuilder({ ...this.#props, onConflictNode: OnConflictNode.cloneWithUpdateWhere(this.#props.onConflictNode, parseValueBinaryOperationOrExpression(args)), }); } /** * Specify a where condition for the update operation. * * See {@link WhereInterface.whereRef} for more info. */ whereRef(lhs, op, rhs) { return new OnConflictUpdateBuilder({ ...this.#props, onConflictNode: OnConflictNode.cloneWithUpdateWhere(this.#props.onConflictNode, parseReferentialBinaryOperation(lhs, op, rhs)), }); } clearWhere() { return new OnConflictUpdateBuilder({ ...this.#props, onConflictNode: OnConflictNode.cloneWithoutUpdateWhere(this.#props.onConflictNode), }); } /** * Simply calls the provided function passing `this` as the only argument. `$call` returns * what the provided function returns. */ $call(func) { return func(this); } toOperationNode() { return this.#props.onConflictNode; } }
Save
cmd:
run