pqb 0.32.0 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +233 -284
- package/dist/index.js +77 -243
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +78 -243
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -879,6 +879,25 @@ const make = (_op) => {
|
|
|
879
879
|
return setQueryOperators(this, boolean);
|
|
880
880
|
},
|
|
881
881
|
{
|
|
882
|
+
// function to turn the operator expression into SQL
|
|
883
|
+
_op
|
|
884
|
+
}
|
|
885
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
886
|
+
);
|
|
887
|
+
};
|
|
888
|
+
const makeVarArg = (_op) => {
|
|
889
|
+
return Object.assign(
|
|
890
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
891
|
+
function(...args) {
|
|
892
|
+
var _a, _b, _c;
|
|
893
|
+
((_b = (_a = this.q).chain) != null ? _b : _a.chain = []).push(_op, args);
|
|
894
|
+
if ((_c = this.q.parsers) == null ? void 0 : _c[getValueKey]) {
|
|
895
|
+
this.q.parsers[getValueKey] = void 0;
|
|
896
|
+
}
|
|
897
|
+
return setQueryOperators(this, boolean);
|
|
898
|
+
},
|
|
899
|
+
{
|
|
900
|
+
// function to turn the operator expression into SQL
|
|
882
901
|
_op
|
|
883
902
|
}
|
|
884
903
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -961,15 +980,51 @@ const text = __spreadProps$7(__spreadValues$f({}, base), {
|
|
|
961
980
|
(key, value, ctx, quotedAs) => `${key} LIKE '%' || ${quoteValue$1(value, ctx, quotedAs)}`
|
|
962
981
|
)
|
|
963
982
|
});
|
|
983
|
+
const encodeJsonPath = (ctx, path) => addValue(ctx.values, `{${Array.isArray(path) ? path.join(", ") : path}}`);
|
|
984
|
+
const jsonPathQueryOp = (key, [path, options], ctx) => `jsonb_path_query_first(${key}, ${addValue(ctx.values, path)}${(options == null ? void 0 : options.vars) ? `, ${addValue(ctx.values, JSON.stringify(options.vars))}${options.silent ? ", true" : ""}` : (options == null ? void 0 : options.silent) ? ", NULL, true" : ""})`;
|
|
964
985
|
const json = __spreadProps$7(__spreadValues$f({}, base), {
|
|
965
|
-
|
|
966
|
-
(
|
|
986
|
+
jsonPathQueryFirst: Object.assign(
|
|
987
|
+
function(path, options) {
|
|
988
|
+
var _a, _b, _c, _d, _e;
|
|
989
|
+
((_b = (_a = this.q).chain) != null ? _b : _a.chain = []).push(jsonPathQueryOp, [path, options]);
|
|
990
|
+
if ((_c = this.q.parsers) == null ? void 0 : _c[getValueKey]) {
|
|
991
|
+
this.q.parsers[getValueKey] = void 0;
|
|
992
|
+
}
|
|
993
|
+
if (options == null ? void 0 : options.type) {
|
|
994
|
+
const parse = options.type(this.columnTypes).parseFn;
|
|
995
|
+
if (parse)
|
|
996
|
+
((_e = (_d = this.q).parsers) != null ? _e : _d.parsers = {})[getValueKey] = parse;
|
|
997
|
+
}
|
|
998
|
+
return this;
|
|
999
|
+
},
|
|
1000
|
+
{ _op: jsonPathQueryOp }
|
|
967
1001
|
),
|
|
968
1002
|
jsonSupersetOf: make(
|
|
969
1003
|
(key, value, ctx, quotedAs) => `${key} @> ${quoteValue$1(value, ctx, quotedAs, true)}`
|
|
970
1004
|
),
|
|
971
1005
|
jsonSubsetOf: make(
|
|
972
1006
|
(key, value, ctx, quotedAs) => `${key} <@ ${quoteValue$1(value, ctx, quotedAs, true)}`
|
|
1007
|
+
),
|
|
1008
|
+
jsonSet: makeVarArg(
|
|
1009
|
+
(key, [path, value], ctx) => `jsonb_set(${key}, ${encodeJsonPath(ctx, path)}, ${addValue(
|
|
1010
|
+
ctx.values,
|
|
1011
|
+
JSON.stringify(value)
|
|
1012
|
+
)})`
|
|
1013
|
+
),
|
|
1014
|
+
jsonReplace: makeVarArg(
|
|
1015
|
+
(key, [path, value], ctx) => `jsonb_set(${key}, ${encodeJsonPath(ctx, path)}, ${addValue(
|
|
1016
|
+
ctx.values,
|
|
1017
|
+
JSON.stringify(value)
|
|
1018
|
+
)}, false)`
|
|
1019
|
+
),
|
|
1020
|
+
jsonInsert: makeVarArg(
|
|
1021
|
+
(key, [path, value, options], ctx) => `jsonb_insert(${key}, ${encodeJsonPath(ctx, path)}, ${addValue(
|
|
1022
|
+
ctx.values,
|
|
1023
|
+
JSON.stringify(value)
|
|
1024
|
+
)}${(options == null ? void 0 : options.after) ? ", true" : ""})`
|
|
1025
|
+
),
|
|
1026
|
+
jsonRemove: makeVarArg(
|
|
1027
|
+
(key, [path], ctx) => `(${key} #- ${encodeJsonPath(ctx, path)})`
|
|
973
1028
|
)
|
|
974
1029
|
});
|
|
975
1030
|
const Operators = {
|
|
@@ -2075,9 +2130,13 @@ const processWhere = (ands, ctx, table, query, data, quotedAs) => {
|
|
|
2075
2130
|
if ("prototype" in data || "baseQuery" in data) {
|
|
2076
2131
|
const query2 = data;
|
|
2077
2132
|
if (query2.q.expr) {
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2133
|
+
if (query2.q.subQuery === 1) {
|
|
2134
|
+
ands.push(selectToSql(ctx, table, query2.q, quotedAs));
|
|
2135
|
+
} else {
|
|
2136
|
+
const q = joinSubQuery(table, query2);
|
|
2137
|
+
q.q.select = [query2.q.expr];
|
|
2138
|
+
ands.push(`(${getSqlText(makeSQL(q, ctx))})`);
|
|
2139
|
+
}
|
|
2081
2140
|
} else {
|
|
2082
2141
|
pushWhereToSql(
|
|
2083
2142
|
ands,
|
|
@@ -3608,7 +3667,7 @@ const processSelectArg = (q, as, arg, columnAs) => {
|
|
|
3608
3667
|
(q2) => q2,
|
|
3609
3668
|
key
|
|
3610
3669
|
);
|
|
3611
|
-
} else if (((_d = value.q) == null ? void 0 : _d.
|
|
3670
|
+
} else if (((_d = value.q) == null ? void 0 : _d.subQuery) && value.q.expr) {
|
|
3612
3671
|
value = value.q.expr;
|
|
3613
3672
|
}
|
|
3614
3673
|
}
|
|
@@ -3783,7 +3842,7 @@ class SelectItemExpression extends Expression {
|
|
|
3783
3842
|
// except that it will use non-aliasing `columnToSql` when `ctx.aliasValue` is true,
|
|
3784
3843
|
// it is needed for relation sub-queries that returns a single column.
|
|
3785
3844
|
makeSQL(ctx, quotedAs) {
|
|
3786
|
-
return typeof this.item === "string" ? this.item === "*" ? selectAllSql(this.query, this.q, quotedAs) : ctx.aliasValue ? columnToSql(ctx, this.q, this.q.shape, this.item, quotedAs, true) : columnToSqlWithAs(ctx, this.q, this.item, quotedAs, true) : selectedObjectToSQL(ctx,
|
|
3845
|
+
return typeof this.item === "string" ? this.item === "*" ? selectAllSql(this.query, this.q, quotedAs) : ctx.aliasValue ? columnToSql(ctx, this.q, this.q.shape, this.item, quotedAs, true) : columnToSqlWithAs(ctx, this.q, this.item, quotedAs, true) : selectedObjectToSQL(ctx, quotedAs, this.item);
|
|
3787
3846
|
}
|
|
3788
3847
|
}
|
|
3789
3848
|
|
|
@@ -3991,50 +4050,6 @@ function queryJson(self, coalesce) {
|
|
|
3991
4050
|
return q;
|
|
3992
4051
|
}
|
|
3993
4052
|
|
|
3994
|
-
const jsonColumnOrMethodToSql = (ctx, table, column, values, quotedAs) => {
|
|
3995
|
-
return typeof column === "string" ? columnToSql(ctx, table.q, table.q.shape, column, quotedAs) : jsonToSql(ctx, table, column, values, quotedAs);
|
|
3996
|
-
};
|
|
3997
|
-
const jsonToSql = (ctx, table, item, values, quotedAs) => {
|
|
3998
|
-
const json = item.__json;
|
|
3999
|
-
if (json[0] === "pathQuery") {
|
|
4000
|
-
const [, , , column, path, options] = json;
|
|
4001
|
-
return `jsonb_path_query(${jsonColumnOrMethodToSql(
|
|
4002
|
-
ctx,
|
|
4003
|
-
table,
|
|
4004
|
-
column,
|
|
4005
|
-
values,
|
|
4006
|
-
quotedAs
|
|
4007
|
-
)}, ${addValue(values, path)}${(options == null ? void 0 : options.vars) ? `, ${addValue(values, options.vars)}` : ""}${(options == null ? void 0 : options.silent) ? ", true" : ""})`;
|
|
4008
|
-
} else if (json[0] === "set") {
|
|
4009
|
-
const [, , , column, path, value, options] = json;
|
|
4010
|
-
return `jsonb_set(${jsonColumnOrMethodToSql(
|
|
4011
|
-
ctx,
|
|
4012
|
-
table,
|
|
4013
|
-
column,
|
|
4014
|
-
values,
|
|
4015
|
-
quotedAs
|
|
4016
|
-
)}, '{${path.join(", ")}}', ${addValue(values, JSON.stringify(value))}${(options == null ? void 0 : options.createIfMissing) ? ", true" : ""})`;
|
|
4017
|
-
} else if (json[0] === "insert") {
|
|
4018
|
-
const [, , , column, path, value, options] = json;
|
|
4019
|
-
return `jsonb_insert(${jsonColumnOrMethodToSql(
|
|
4020
|
-
ctx,
|
|
4021
|
-
table,
|
|
4022
|
-
column,
|
|
4023
|
-
values,
|
|
4024
|
-
quotedAs
|
|
4025
|
-
)}, '{${path.join(", ")}}', ${addValue(values, JSON.stringify(value))}${(options == null ? void 0 : options.insertAfter) ? ", true" : ""})`;
|
|
4026
|
-
} else if (json[0] === "remove") {
|
|
4027
|
-
const [, , , column, path] = json;
|
|
4028
|
-
return `${jsonColumnOrMethodToSql(
|
|
4029
|
-
ctx,
|
|
4030
|
-
table,
|
|
4031
|
-
column,
|
|
4032
|
-
values,
|
|
4033
|
-
quotedAs
|
|
4034
|
-
)} #- '{${path.join(", ")}}'`;
|
|
4035
|
-
}
|
|
4036
|
-
return "";
|
|
4037
|
-
};
|
|
4038
4053
|
const pushSelectSql = (ctx, table, query, quotedAs) => {
|
|
4039
4054
|
ctx.sql.push(selectToSql(ctx, table, query, quotedAs));
|
|
4040
4055
|
};
|
|
@@ -4068,7 +4083,7 @@ const selectToSql = (ctx, table, query, quotedAs) => {
|
|
|
4068
4083
|
}
|
|
4069
4084
|
}
|
|
4070
4085
|
} else {
|
|
4071
|
-
list.push(selectedObjectToSQL(ctx,
|
|
4086
|
+
list.push(selectedObjectToSQL(ctx, quotedAs, item));
|
|
4072
4087
|
}
|
|
4073
4088
|
}
|
|
4074
4089
|
return list.join(", ");
|
|
@@ -4076,10 +4091,7 @@ const selectToSql = (ctx, table, query, quotedAs) => {
|
|
|
4076
4091
|
return selectAllSql(table, query, quotedAs);
|
|
4077
4092
|
};
|
|
4078
4093
|
const selectedStringToSQL = (ctx, table, query, quotedAs, item) => item === "*" ? selectAllSql(table, query, quotedAs) : columnToSqlWithAs(ctx, table.q, item, quotedAs, true);
|
|
4079
|
-
function selectedObjectToSQL(ctx,
|
|
4080
|
-
if ("__json" in item) {
|
|
4081
|
-
return `${jsonToSql(ctx, table, item, ctx.values, quotedAs)} "${item.__json[1]}"`;
|
|
4082
|
-
}
|
|
4094
|
+
function selectedObjectToSQL(ctx, quotedAs, item) {
|
|
4083
4095
|
const sql = item.toSQL(ctx, quotedAs);
|
|
4084
4096
|
return ctx.aliasValue ? `${sql} r` : sql;
|
|
4085
4097
|
}
|
|
@@ -4769,11 +4781,12 @@ const processData = (ctx, table, set, data, quotedAs) => {
|
|
|
4769
4781
|
};
|
|
4770
4782
|
const processValue = (ctx, table, QueryClass, key, value, quotedAs) => {
|
|
4771
4783
|
if (value && typeof value === "object") {
|
|
4772
|
-
if (value
|
|
4773
|
-
return jsonToSql(ctx, table, value, ctx.values, quotedAs);
|
|
4774
|
-
} else if (isExpression(value)) {
|
|
4784
|
+
if (isExpression(value)) {
|
|
4775
4785
|
return value.toSQL(ctx, quotedAs);
|
|
4776
4786
|
} else if (value instanceof QueryClass) {
|
|
4787
|
+
if (value.q.subQuery === 1) {
|
|
4788
|
+
return selectToSql(ctx, table, value.q, quotedAs);
|
|
4789
|
+
}
|
|
4777
4790
|
return `(${getSqlText(
|
|
4778
4791
|
joinSubQuery(table, value).toSQL(ctx)
|
|
4779
4792
|
)})`;
|
|
@@ -5199,11 +5212,11 @@ const makeRegexToFindInSql = (value) => {
|
|
|
5199
5212
|
return new RegExp(`${value}(?=(?:[^']*'[^']*')*[^']*$)`, "g");
|
|
5200
5213
|
};
|
|
5201
5214
|
const resolveSubQueryCallback = (q, cb) => {
|
|
5202
|
-
const {
|
|
5203
|
-
q.q.
|
|
5215
|
+
const { subQuery, relChain } = q.q;
|
|
5216
|
+
q.q.subQuery = 1;
|
|
5204
5217
|
q.q.relChain = void 0;
|
|
5205
5218
|
const result = cb(q);
|
|
5206
|
-
q.q.
|
|
5219
|
+
q.q.subQuery = subQuery;
|
|
5207
5220
|
q.q.relChain = relChain;
|
|
5208
5221
|
return result;
|
|
5209
5222
|
};
|
|
@@ -6653,7 +6666,7 @@ class Create {
|
|
|
6653
6666
|
* const createdCount = await db.table.insertMany([data, data, data]);
|
|
6654
6667
|
* ```
|
|
6655
6668
|
*
|
|
6656
|
-
* Because of a limitation of Postgres protocol, queries having more than **
|
|
6669
|
+
* Because of a limitation of Postgres protocol, queries having more than **65535** of values are going to fail in runtime.
|
|
6657
6670
|
* To solve this seamlessly, OrchidORM will automatically batch such queries, and wrap them into a transaction, unless they are already in a transaction.
|
|
6658
6671
|
*
|
|
6659
6672
|
* ```ts
|
|
@@ -8275,183 +8288,6 @@ class OnMethods {
|
|
|
8275
8288
|
}
|
|
8276
8289
|
}
|
|
8277
8290
|
|
|
8278
|
-
class JsonModifiers {
|
|
8279
|
-
/**
|
|
8280
|
-
* Return a JSON value/object/array where a given value is set at the given path.
|
|
8281
|
-
* The path is an array of keys to access the value.
|
|
8282
|
-
*
|
|
8283
|
-
* Can be used in `update` callback.
|
|
8284
|
-
*
|
|
8285
|
-
* ```ts
|
|
8286
|
-
* const result = await db.table.jsonSet('data', ['name'], 'new value').take();
|
|
8287
|
-
*
|
|
8288
|
-
* expect(result.data).toEqual({ name: 'new value' });
|
|
8289
|
-
* ```
|
|
8290
|
-
*
|
|
8291
|
-
* Optionally takes parameters of type `{ as?: string, createIfMissing?: boolean }`
|
|
8292
|
-
*
|
|
8293
|
-
* ```ts
|
|
8294
|
-
* await db.table.jsonSet('data', ['name'], 'new value', {
|
|
8295
|
-
* as: 'alias', // select data as `alias`
|
|
8296
|
-
* createIfMissing: true, // ignored if missing by default
|
|
8297
|
-
* });
|
|
8298
|
-
* ```
|
|
8299
|
-
*
|
|
8300
|
-
* @param column - name of JSON column, or a result of a nested json method
|
|
8301
|
-
* @param path - path to value inside the json
|
|
8302
|
-
* @param value - value to set into the json
|
|
8303
|
-
* @param options - `as` to alias the json value when selecting, `createIfMissing: true` will create a new JSON property if it didn't exist before
|
|
8304
|
-
*/
|
|
8305
|
-
jsonSet(column, path, value, options) {
|
|
8306
|
-
var _a;
|
|
8307
|
-
const q = this.clone();
|
|
8308
|
-
const json = {
|
|
8309
|
-
__json: [
|
|
8310
|
-
"set",
|
|
8311
|
-
(_a = options == null ? void 0 : options.as) != null ? _a : typeof column === "string" ? column : column.__json[1],
|
|
8312
|
-
typeof column === "string" ? q.q.shape[column] : column.__json[2],
|
|
8313
|
-
column,
|
|
8314
|
-
path,
|
|
8315
|
-
value,
|
|
8316
|
-
options
|
|
8317
|
-
]
|
|
8318
|
-
};
|
|
8319
|
-
return Object.assign(pushQueryValue(q, "select", json), json);
|
|
8320
|
-
}
|
|
8321
|
-
/**
|
|
8322
|
-
* Return a JSON value/object/array where a given value is inserted at the given JSON path. Value can be a single value or JSON object. If a value exists at the given path, the value is not replaced.
|
|
8323
|
-
*
|
|
8324
|
-
* Can be used in `update` callback.
|
|
8325
|
-
*
|
|
8326
|
-
* ```ts
|
|
8327
|
-
* // imagine user has data = { tags: ['two'] }
|
|
8328
|
-
* const result = await db.table.jsonInsert('data', ['tags', 0], 'one').take();
|
|
8329
|
-
*
|
|
8330
|
-
* // 'one' is inserted to 0 position
|
|
8331
|
-
* expect(result.data).toEqual({ tags: ['one', 'two'] });
|
|
8332
|
-
* ```
|
|
8333
|
-
*
|
|
8334
|
-
* Optionally takes parameters of type `{ as?: string, insertAfter?: boolean }`
|
|
8335
|
-
*
|
|
8336
|
-
* ```ts
|
|
8337
|
-
* // imagine user has data = { tags: ['one'] }
|
|
8338
|
-
* const result = await db.table
|
|
8339
|
-
* .jsonInsert('data', ['tags', 0], 'two', {
|
|
8340
|
-
* as: 'alias', // select as an alias
|
|
8341
|
-
* insertAfter: true, // insert after the specified position
|
|
8342
|
-
* })
|
|
8343
|
-
* .take();
|
|
8344
|
-
*
|
|
8345
|
-
* // 'one' is inserted to 0 position
|
|
8346
|
-
* expect(result.alias).toEqual({ tags: ['one', 'two'] });
|
|
8347
|
-
* ```
|
|
8348
|
-
* @param column - name of JSON column, or a result of a nested json method
|
|
8349
|
-
* @param path - path to the array inside the json, last path element is index to insert into
|
|
8350
|
-
* @param value - value to insert into the json array
|
|
8351
|
-
* @param options - `as` to alias the json value when selecting, `insertAfter: true` to insert after the specified position
|
|
8352
|
-
*/
|
|
8353
|
-
jsonInsert(column, path, value, options) {
|
|
8354
|
-
var _a;
|
|
8355
|
-
const q = this.clone();
|
|
8356
|
-
const json = {
|
|
8357
|
-
__json: [
|
|
8358
|
-
"insert",
|
|
8359
|
-
(_a = options == null ? void 0 : options.as) != null ? _a : typeof column === "string" ? column : column.__json[1],
|
|
8360
|
-
typeof column === "string" ? q.q.shape[column] : column.__json[2],
|
|
8361
|
-
column,
|
|
8362
|
-
path,
|
|
8363
|
-
value,
|
|
8364
|
-
options
|
|
8365
|
-
]
|
|
8366
|
-
};
|
|
8367
|
-
return Object.assign(pushQueryValue(q, "select", json), json);
|
|
8368
|
-
}
|
|
8369
|
-
/**
|
|
8370
|
-
* Return a JSON value/object/array where a given value is removed at the given JSON path.
|
|
8371
|
-
*
|
|
8372
|
-
* Can be used in `update` callback.
|
|
8373
|
-
*
|
|
8374
|
-
* ```ts
|
|
8375
|
-
* // imagine a user has data = { tags: ['one', 'two'] }
|
|
8376
|
-
* const result = await db.table
|
|
8377
|
-
* .jsonRemove(
|
|
8378
|
-
* 'data',
|
|
8379
|
-
* ['tags', 0],
|
|
8380
|
-
* // optional parameters:
|
|
8381
|
-
* {
|
|
8382
|
-
* as: 'alias', // select as an alias
|
|
8383
|
-
* },
|
|
8384
|
-
* )
|
|
8385
|
-
* .take();
|
|
8386
|
-
*
|
|
8387
|
-
* expect(result.alias).toEqual({ tags: ['two'] });
|
|
8388
|
-
* ```
|
|
8389
|
-
*
|
|
8390
|
-
* @param column - name of JSON column, or a result of a nested json method
|
|
8391
|
-
* @param path - path to the array inside the json, last path element is index to remove this element
|
|
8392
|
-
* @param options - `as` to alias the json value when selecting
|
|
8393
|
-
*/
|
|
8394
|
-
jsonRemove(column, path, options) {
|
|
8395
|
-
var _a;
|
|
8396
|
-
const q = this.clone();
|
|
8397
|
-
const json = {
|
|
8398
|
-
__json: [
|
|
8399
|
-
"remove",
|
|
8400
|
-
(_a = options == null ? void 0 : options.as) != null ? _a : typeof column === "string" ? column : column.__json[1],
|
|
8401
|
-
typeof column === "string" ? q.q.shape[column] : column.__json[2],
|
|
8402
|
-
column,
|
|
8403
|
-
path
|
|
8404
|
-
]
|
|
8405
|
-
};
|
|
8406
|
-
return Object.assign(pushQueryValue(q, "select", json), json);
|
|
8407
|
-
}
|
|
8408
|
-
/**
|
|
8409
|
-
* Selects a value from JSON data using a JSON path.
|
|
8410
|
-
*
|
|
8411
|
-
* ```ts
|
|
8412
|
-
* import { columnTypes } from 'orchid-orm';
|
|
8413
|
-
*
|
|
8414
|
-
* db.table.jsonPathQuery(
|
|
8415
|
-
* columnTypes.text(3, 100), // type of the value
|
|
8416
|
-
* 'data', // name of the JSON column
|
|
8417
|
-
* '$.name', // JSON path
|
|
8418
|
-
* 'name', // select value as name
|
|
8419
|
-
*
|
|
8420
|
-
* // Optionally supports `vars` and `silent` options
|
|
8421
|
-
* // check Postgres docs for jsonb_path_query for details
|
|
8422
|
-
* {
|
|
8423
|
-
* vars: 'vars',
|
|
8424
|
-
* silent: true,
|
|
8425
|
-
* },
|
|
8426
|
-
* );
|
|
8427
|
-
* ```
|
|
8428
|
-
*
|
|
8429
|
-
* Nested JSON operations can be used in place of JSON column name:
|
|
8430
|
-
*
|
|
8431
|
-
* ```ts
|
|
8432
|
-
* db.table.jsonPathQuery(
|
|
8433
|
-
* columnTypes.text(3, 100),
|
|
8434
|
-
* // Available: .jsonSet, .jsonInsert, .jsonRemove
|
|
8435
|
-
* db.table.jsonSet('data', ['key'], 'value'),
|
|
8436
|
-
* '$.name',
|
|
8437
|
-
* 'name',
|
|
8438
|
-
* );
|
|
8439
|
-
* ```
|
|
8440
|
-
*
|
|
8441
|
-
* @param type - provide a column type to have a correct result type
|
|
8442
|
-
* @param column - name of JSON column, or a result of a nested json method
|
|
8443
|
-
* @param path - special JSON path string to reference a JSON value
|
|
8444
|
-
* @param as - optional alias for the selected value
|
|
8445
|
-
* @param options - supports `vars` and `silent`, check Postgres docs of `json_path_query` for these
|
|
8446
|
-
*/
|
|
8447
|
-
jsonPathQuery(type, column, path, as, options) {
|
|
8448
|
-
const q = this.clone();
|
|
8449
|
-
const json = {
|
|
8450
|
-
__json: ["pathQuery", as, type, column, path, options]
|
|
8451
|
-
};
|
|
8452
|
-
return Object.assign(pushQueryValue(q, "select", json), json);
|
|
8453
|
-
}
|
|
8454
|
-
}
|
|
8455
8291
|
class JsonMethods {
|
|
8456
8292
|
/**
|
|
8457
8293
|
* Wraps the query in a way to select a single JSON string.
|
|
@@ -8827,7 +8663,7 @@ const resolveCallbacksInArgs = (q, args) => {
|
|
|
8827
8663
|
const qb = Object.create(q);
|
|
8828
8664
|
qb.q = getClonedQueryData(q.q);
|
|
8829
8665
|
qb.q.and = qb.q.or = qb.q.scopes = void 0;
|
|
8830
|
-
qb.q.
|
|
8666
|
+
qb.q.subQuery = 1;
|
|
8831
8667
|
args[i] = resolveSubQueryCallback(qb, arg);
|
|
8832
8668
|
}
|
|
8833
8669
|
}
|
|
@@ -11540,7 +11376,6 @@ applyMixins(QueryMethods, [
|
|
|
11540
11376
|
OnMethods,
|
|
11541
11377
|
WithMethods,
|
|
11542
11378
|
Union,
|
|
11543
|
-
JsonModifiers,
|
|
11544
11379
|
JsonMethods,
|
|
11545
11380
|
Create,
|
|
11546
11381
|
Update,
|
|
@@ -12135,5 +11970,5 @@ function copyTableData(query, arg) {
|
|
|
12135
11970
|
return q;
|
|
12136
11971
|
}
|
|
12137
11972
|
|
|
12138
|
-
export { Adapter, AggregateMethods, ArrayColumn, AsMethods, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BoxColumn, ByteaColumn, CharColumn, CidrColumn, CircleColumn, CitextColumn, Clear, ColumnRefExpression, ColumnType, Create, CustomTypeColumn, DateBaseColumn, DateColumn, DateTimeBaseClass, DateTimeTzBaseClass, Db, DecimalColumn, Delete, DomainColumn, DoublePrecisionColumn, DynamicRawSQL, EnumColumn, ExpressionMethods, FnExpression, For, FromMethods, Having, InetColumn, IntegerBaseColumn, IntegerColumn, IntervalColumn, JSONColumn, JSONTextColumn, Join, JsonMethods,
|
|
11973
|
+
export { Adapter, AggregateMethods, ArrayColumn, AsMethods, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BoxColumn, ByteaColumn, CharColumn, CidrColumn, CircleColumn, CitextColumn, Clear, ColumnRefExpression, ColumnType, Create, CustomTypeColumn, DateBaseColumn, DateColumn, DateTimeBaseClass, DateTimeTzBaseClass, Db, DecimalColumn, Delete, DomainColumn, DoublePrecisionColumn, DynamicRawSQL, EnumColumn, ExpressionMethods, FnExpression, For, FromMethods, Having, InetColumn, IntegerBaseColumn, IntegerColumn, IntervalColumn, JSONColumn, JSONTextColumn, Join, JsonMethods, LimitedTextBaseColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, MergeQueryMethods, MoneyColumn, MoreThanOneRowError, NotFoundError, NumberAsStringBaseColumn, NumberBaseColumn, OnConflictQueryBuilder, OnMethods, Operators, OrExpression, OrchidOrmError, OrchidOrmInternalError, PathColumn, PointColumn, PolygonColumn, QueryBase, QueryError, QueryGet, QueryHooks, QueryLog, QueryMethods, QueryUpsertOrCreate, RawSQL, RealColumn, RefExpression, SearchMethods, Select, SerialColumn, SmallIntColumn, SmallSerialColumn, SqlMethod, StringColumn, TextBaseColumn, TextColumn, Then, TimeColumn, TimestampColumn, TimestampTZColumn, Transaction, TransactionAdapter, TransformMethods, TsQueryColumn, TsVectorColumn, UUIDColumn, UnhandledTypeError, Union, UnknownColumn, Update, VarCharColumn, VirtualColumn, Where, WithMethods, XMLColumn, _initQueryBuilder, _queryAfterSaveCommit, _queryAll, _queryAs, _queryChangeCounter, _queryCreate, _queryCreateFrom, _queryCreateMany, _queryCreateManyFrom, _queryCreateManyRaw, _queryCreateRaw, _queryDefaults, _queryDelete, _queryExec, _queryFindBy, _queryFindByOptional, _queryGet, _queryGetOptional, _queryHookAfterCreate, _queryHookAfterCreateCommit, _queryHookAfterDelete, _queryHookAfterDeleteCommit, _queryHookAfterQuery, _queryHookAfterSave, _queryHookAfterUpdate, _queryHookAfterUpdateCommit, _queryHookBeforeCreate, _queryHookBeforeDelete, _queryHookBeforeQuery, _queryHookBeforeSave, _queryHookBeforeUpdate, _queryInsert, _queryInsertFrom, _queryInsertMany, _queryInsertManyFrom, _queryInsertManyRaw, _queryInsertRaw, _queryJoinOn, _queryJoinOnJsonPathEquals, _queryJoinOrOn, _queryOr, _queryOrNot, _queryRows, _querySelect, _queryTake, _queryTakeOptional, _queryUnion, _queryUpdate, _queryUpdateOrThrow, _queryUpdateRaw, _queryWhere, _queryWhereExists, _queryWhereIn, _queryWhereNot, _queryWhereNotSql, _queryWhereSql, addComputedColumns, addParserForRawExpression, addParserForSelectItem, addQueryOn, anyShape, checkIfASimpleQuery, cloneQuery, cloneQueryBaseUnscoped, columnCheckToCode, columnCode, columnForeignKeysToCode, columnIndexesToCode, columnsShapeToCode, commitSql$1 as commitSql, constraintInnerToCode, constraintToCode, copyTableData, countSelect, createDb, defaultSchemaConfig, extendQuery, foreignKeyArgumentToCode, getClonedQueryData, getColumnInfo, getColumnTypes, getPrimaryKeys, getQueryAs, getShapeFromSelect, getSqlText, handleResult, identityToCode, indexInnerToCode, indexToCode, instantiateColumn, isDefaultTimeStamp, isQueryReturnsAll, isSelectingCount, joinSubQuery, logColors, logParamToLogObject, makeColumnTypes, makeColumnsByType, makeFnExpression, makeRegexToFindInSql, makeSQL, parseRecord, parseResult, parseTableData, parseTableDataInput, primaryKeyInnerToCode, processSelectArg, pushLimitSQL, pushQueryArray, pushQueryOn, pushQueryOrOn, pushQueryValue, pushTableDataCode, queryFrom, queryFromSql, queryJson, queryMethodByReturnType, queryTypeWithLimitOne, queryWrap, quote, quoteString, raw, referencesArgsToCode, resolveSubQueryCallback, rollbackSql$1 as rollbackSql, saveSearchAlias, setParserForSelectedString, setQueryObjectValue, setQueryOperators, simplifyColumnDefault, sqlFn, sqlQueryArgsToExpression, tableDataMethods, templateLiteralToSQL, testTransaction, throwIfNoWhere, toSQL, toSQLCacheKey };
|
|
12139
11974
|
//# sourceMappingURL=index.mjs.map
|