diff --git a/lib/query/querycompiler.js b/lib/query/querycompiler.js index eb44b924ea..5daee42c8e 100644 --- a/lib/query/querycompiler.js +++ b/lib/query/querycompiler.js @@ -1413,19 +1413,6 @@ class QueryCompiler { .join(', '); } - _getExtracts(nameFunction, statement, operator) { - return ( - Array.isArray(statement.values) ? statement.values : [statement.values] - ) - .map(function (value) { - return this._jsonExtract(nameFunction, { - column: statement.column, - path: value, - }); - }, this) - .join(operator); - } - _jsonSet(nameFunction, params) { const jsonSet = `${nameFunction}(${columnize_( params.column, diff --git a/types/index.d.ts b/types/index.d.ts index 2a774ffe01..ab3da1a29f 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -509,6 +509,12 @@ export declare namespace Knex { fullOuterJoin: Join; crossJoin: Join; + // Json manipulation + jsonExtract : JsonExtract; + jsonSet: JsonSet; + jsonInsert: JsonInsert; + jsonRemove: JsonRemove; + // Using using: Using; @@ -1122,6 +1128,30 @@ export declare namespace Knex { ): QueryBuilder; } + interface JsonExtraction { + column: string | Raw | QueryBuilder; + path: string; + alias?: string; + singleValue?: boolean; + } + + interface JsonExtract { + (column: string | Raw | QueryBuilder, path: string, alias?: string, singleValue?: boolean): QueryBuilder; + (column: JsonExtraction[] | any[][], singleValue?: boolean): QueryBuilder; + } + + interface JsonSet { + (column: string | Raw | QueryBuilder, path: string, value: any, alias?: string): QueryBuilder; + } + + interface JsonInsert { + (column: string | Raw | QueryBuilder, path: string, value: any, alias?: string): QueryBuilder; + } + + interface JsonRemove { + (column: string | Raw | QueryBuilder, path: string, value: any, alias?: string): QueryBuilder; + } + interface HintComment { (hint: string): QueryBuilder; (hints: readonly string[]): QueryBuilder;