/opt/canhelp/node_modules/kysely/dist/cjs/query-builder
NameSizeModeActions
aggregate-function-builder.d.ts136020644editdlrm
aggregate-function-builder.js82760644editdlrm
case-builder.d.ts66890644editdlrm
case-builder.js33530644editdlrm
cte-builder.d.ts8020644editdlrm
cte-builder.js11600644editdlrm
delete-query-builder.d.ts474430644editdlrm
delete-query-builder.js165990644editdlrm
delete-result.d.ts1160644editdlrm
delete-result.js2740644editdlrm
function-module.d.ts235210644editdlrm
function-module.js28560644editdlrm
having-interface.d.ts9530644editdlrm
having-interface.js770644editdlrm
insert-query-builder.d.ts402150644editdlrm
insert-query-builder.js368130644editdlrm
insert-result.d.ts17350644editdlrm
insert-result.js18740644editdlrm
join-builder.d.ts17730644editdlrm
join-builder.js18060644editdlrm
json-path-builder.d.ts95450644editdlrm
json-path-builder.js64180644editdlrm
merge-query-builder.d.ts370250644editdlrm
merge-query-builder.js216260644editdlrm
merge-result.d.ts1390644editdlrm
merge-result.js2700644editdlrm
no-result-error.d.ts4780644editdlrm
no-result-error.js5340644editdlrm
on-conflict-builder.d.ts255730644editdlrm
on-conflict-builder.js90280644editdlrm
order-by-interface.d.ts48830644editdlrm
order-by-interface.js770644editdlrm
order-by-item-builder.d.ts13720644editdlrm
order-by-item-builder.js24570644editdlrm
output-interface.d.ts54770644editdlrm
output-interface.js770644editdlrm
over-builder.d.ts37550644editdlrm
over-builder.js14950644editdlrm
returning-interface.d.ts34960644editdlrm
returning-interface.js770644editdlrm
select-query-builder-expression.d.ts9620644editdlrm
select-query-builder-expression.js770644editdlrm
select-query-builder.d.ts784670644editdlrm
select-query-builder.js150380644editdlrm
update-query-builder.d.ts502540644editdlrm
update-query-builder.js172360644editdlrm
update-result.d.ts4970644editdlrm
update-result.js6630644editdlrm
where-interface.d.ts108140644editdlrm
where-interface.js770644editdlrm
Edit: /opt/canhelp/node_modules/kysely/dist/cjs/query-builder/json-path-builder.js (6418B)
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AliasedJSONPathBuilder = exports.TraversedJSONPathBuilder = exports.JSONPathBuilder = void 0; const alias_node_js_1 = require("../operation-node/alias-node.js"); const identifier_node_js_1 = require("../operation-node/identifier-node.js"); const json_operator_chain_node_js_1 = require("../operation-node/json-operator-chain-node.js"); const json_path_leg_node_js_1 = require("../operation-node/json-path-leg-node.js"); const json_path_node_js_1 = require("../operation-node/json-path-node.js"); const json_reference_node_js_1 = require("../operation-node/json-reference-node.js"); const operation_node_source_js_1 = require("../operation-node/operation-node-source.js"); const value_node_js_1 = require("../operation-node/value-node.js"); class JSONPathBuilder { #node; constructor(node) { this.#node = node; } /** * Access an element of a JSON array in a specific location. * * Since there's no guarantee an element exists in the given array location, the * resulting type is always nullable. If you're sure the element exists, you * should use {@link SelectQueryBuilder.$assertType} to narrow the type safely. * * See also {@link key} to access properties of JSON objects. * * ### Examples * * ```ts * await db.selectFrom('person') * .select(eb => * eb.ref('nicknames', '->').at(0).as('primary_nickname') * ) * .execute() * ``` * * The generated SQL (PostgreSQL): * * ```sql * select "nicknames"->0 as "primary_nickname" from "person" *``` * * Combined with {@link key}: * * ```ts * db.selectFrom('person').select(eb => * eb.ref('experience', '->').at(0).key('role').as('first_role') * ) * ``` * * The generated SQL (PostgreSQL): * * ```sql * select "experience"->0->'role' as "first_role" from "person" * ``` * * You can use `'last'` to access the last element of the array in MySQL: * * ```ts * db.selectFrom('person').select(eb => * eb.ref('nicknames', '->$').at('last').as('last_nickname') * ) * ``` * * The generated SQL (MySQL): * * ```sql * select `nicknames`->'$[last]' as `last_nickname` from `person` * ``` * * Or `'#-1'` in SQLite: * * ```ts * db.selectFrom('person').select(eb => * eb.ref('nicknames', '->>$').at('#-1').as('last_nickname') * ) * ``` * * The generated SQL (SQLite): * * ```sql * select "nicknames"->>'$[#-1]' as `last_nickname` from `person` * ``` */ at(index) { return this.#createBuilderWithPathLeg('ArrayLocation', index); } /** * Access a property of a JSON object. * * If a field is optional, the resulting type will be nullable. * * See also {@link at} to access elements of JSON arrays. * * ### Examples * * ```ts * db.selectFrom('person').select(eb => * eb.ref('address', '->').key('city').as('city') * ) * ``` * * The generated SQL (PostgreSQL): * * ```sql * select "address"->'city' as "city" from "person" * ``` * * Going deeper: * * ```ts * db.selectFrom('person').select(eb => * eb.ref('profile', '->$').key('website').key('url').as('website_url') * ) * ``` * * The generated SQL (MySQL): * * ```sql * select `profile`->'$.website.url' as `website_url` from `person` * ``` * * Combined with {@link at}: * * ```ts * db.selectFrom('person').select(eb => * eb.ref('profile', '->').key('addresses').at(0).key('city').as('city') * ) * ``` * * The generated SQL (PostgreSQL): * * ```sql * select "profile"->'addresses'->0->'city' as "city" from "person" * ``` */ key(key) { return this.#createBuilderWithPathLeg('Member', key); } #createBuilderWithPathLeg(legType, value) { if (json_reference_node_js_1.JSONReferenceNode.is(this.#node)) { return new TraversedJSONPathBuilder(json_reference_node_js_1.JSONReferenceNode.cloneWithTraversal(this.#node, json_path_node_js_1.JSONPathNode.is(this.#node.traversal) ? json_path_node_js_1.JSONPathNode.cloneWithLeg(this.#node.traversal, json_path_leg_node_js_1.JSONPathLegNode.create(legType, value)) : json_operator_chain_node_js_1.JSONOperatorChainNode.cloneWithValue(this.#node.traversal, value_node_js_1.ValueNode.createImmediate(value)))); } return new TraversedJSONPathBuilder(json_path_node_js_1.JSONPathNode.cloneWithLeg(this.#node, json_path_leg_node_js_1.JSONPathLegNode.create(legType, value))); } } exports.JSONPathBuilder = JSONPathBuilder; class TraversedJSONPathBuilder extends JSONPathBuilder { #node; constructor(node) { super(node); this.#node = node; } /** @private */ get expressionType() { return undefined; } as(alias) { return new AliasedJSONPathBuilder(this, alias); } /** * Change the output type of the json path. * * This method call doesn't change the SQL in any way. This methods simply * returns a copy of this `JSONPathBuilder` with a new output type. */ $castTo() { return new TraversedJSONPathBuilder(this.#node); } $notNull() { return new TraversedJSONPathBuilder(this.#node); } toOperationNode() { return this.#node; } } exports.TraversedJSONPathBuilder = TraversedJSONPathBuilder; class AliasedJSONPathBuilder { #jsonPath; #alias; constructor(jsonPath, alias) { this.#jsonPath = jsonPath; this.#alias = alias; } /** @private */ get expression() { return this.#jsonPath; } /** @private */ get alias() { return this.#alias; } toOperationNode() { return alias_node_js_1.AliasNode.create(this.#jsonPath.toOperationNode(), (0, operation_node_source_js_1.isOperationNodeSource)(this.#alias) ? this.#alias.toOperationNode() : identifier_node_js_1.IdentifierNode.create(this.#alias)); } } exports.AliasedJSONPathBuilder = AliasedJSONPathBuilder;