pqb 0.69.0 → 0.70.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 +226 -200
- package/dist/index.js +60 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +60 -18
- package/dist/index.mjs.map +1 -1
- package/dist/internal.d.ts +203 -178
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -8029,22 +8029,6 @@ const numericResultColumn = (q, arg) => {
|
|
|
8029
8029
|
return (typeof arg === "string" ? _getSelectableColumn(q, arg) : arg.result.value) instanceof NumberBaseColumn ? floatNullable : stringAsNumberNullable;
|
|
8030
8030
|
};
|
|
8031
8031
|
var AggregateMethods = class {
|
|
8032
|
-
/**
|
|
8033
|
-
* Use `exists()` to check if there is at least one record-matching condition.
|
|
8034
|
-
*
|
|
8035
|
-
* It will discard previous `select` statements if any. Returns a boolean.
|
|
8036
|
-
*
|
|
8037
|
-
* ```ts
|
|
8038
|
-
* const exists: boolean = await db.table.where(...conditions).exists();
|
|
8039
|
-
* ```
|
|
8040
|
-
*/
|
|
8041
|
-
exists() {
|
|
8042
|
-
const q = _queryGetOptional(_clone(this), new RawSql("true"));
|
|
8043
|
-
q.q.notFoundDefault = false;
|
|
8044
|
-
q.q.coalesceValue = new RawSql("false");
|
|
8045
|
-
q.q.getColumn = BooleanColumn.instanceSkipValueToArray;
|
|
8046
|
-
return q;
|
|
8047
|
-
}
|
|
8048
8032
|
/**
|
|
8049
8033
|
* Count records with the `count` function:
|
|
8050
8034
|
*
|
|
@@ -13265,6 +13249,39 @@ var QueryWindow = class {
|
|
|
13265
13249
|
return pushQueryValueImmutable(_clone(this), "window", arg);
|
|
13266
13250
|
}
|
|
13267
13251
|
};
|
|
13252
|
+
const _exists = (query, value) => {
|
|
13253
|
+
const q = _queryGetOptional(_clone(query), new RawSql(String(value)));
|
|
13254
|
+
q.q.notFoundDefault = !value;
|
|
13255
|
+
q.q.coalesceValue = new RawSql(String(!value));
|
|
13256
|
+
q.q.getColumn = BooleanColumn.instanceSkipValueToArray;
|
|
13257
|
+
return q;
|
|
13258
|
+
};
|
|
13259
|
+
var QueryExistsMethods = class {
|
|
13260
|
+
/**
|
|
13261
|
+
* Use `exists()` to check if there is at least one record-matching condition.
|
|
13262
|
+
*
|
|
13263
|
+
* It will discard previous `select` statements if any. Returns a boolean.
|
|
13264
|
+
*
|
|
13265
|
+
* ```ts
|
|
13266
|
+
* const exists: boolean = await db.table.where(...conditions).exists();
|
|
13267
|
+
* ```
|
|
13268
|
+
*/
|
|
13269
|
+
exists() {
|
|
13270
|
+
return _exists(this, true);
|
|
13271
|
+
}
|
|
13272
|
+
/**
|
|
13273
|
+
* Use `notExists()` to check if there are no matching records.
|
|
13274
|
+
*
|
|
13275
|
+
* It will discard previous `select` statements if any. Returns a boolean.
|
|
13276
|
+
*
|
|
13277
|
+
* ```ts
|
|
13278
|
+
* const exists: boolean = await db.table.where(...conditions).notExists();
|
|
13279
|
+
* ```
|
|
13280
|
+
*/
|
|
13281
|
+
notExists() {
|
|
13282
|
+
return _exists(this, false);
|
|
13283
|
+
}
|
|
13284
|
+
};
|
|
13268
13285
|
var QueryMethods = class {
|
|
13269
13286
|
/**
|
|
13270
13287
|
* `.all` is a default behavior, that returns an array of objects:
|
|
@@ -13338,6 +13355,30 @@ var QueryMethods = class {
|
|
|
13338
13355
|
return _queryExec(_clone(this));
|
|
13339
13356
|
}
|
|
13340
13357
|
/**
|
|
13358
|
+
* For relation selects, `require` changes LEFT JOIN LATERAL to JOIN LATERAL.
|
|
13359
|
+
*
|
|
13360
|
+
* ```ts
|
|
13361
|
+
* // only the records that have `related` will be loaded:
|
|
13362
|
+
* await db.table.select({ related: (q) => q.related.required() });
|
|
13363
|
+
* ```
|
|
13364
|
+
*/
|
|
13365
|
+
require() {
|
|
13366
|
+
const query = _clone(this);
|
|
13367
|
+
switch (query.q.returnType) {
|
|
13368
|
+
case void 0:
|
|
13369
|
+
case "all":
|
|
13370
|
+
case "valueOrThrow":
|
|
13371
|
+
case "pluck":
|
|
13372
|
+
case "void": break;
|
|
13373
|
+
case "value":
|
|
13374
|
+
query.q.returnType = "valueOrThrow";
|
|
13375
|
+
break;
|
|
13376
|
+
default: query.q.returnType = "oneOrThrow";
|
|
13377
|
+
}
|
|
13378
|
+
query.q.innerJoinLateral = true;
|
|
13379
|
+
return query;
|
|
13380
|
+
}
|
|
13381
|
+
/**
|
|
13341
13382
|
* Call `toSQL` on a query to get an object with a `text` SQL string and a `values` array of binding values:
|
|
13342
13383
|
*
|
|
13343
13384
|
* ```ts
|
|
@@ -13541,7 +13582,7 @@ var QueryMethods = class {
|
|
|
13541
13582
|
* // all the following queries will resolve into empty arrays
|
|
13542
13583
|
*
|
|
13543
13584
|
* await db.user.select({
|
|
13544
|
-
* pets: (q) => q.pets.
|
|
13585
|
+
* pets: (q) => q.pets.require().none(),
|
|
13545
13586
|
* });
|
|
13546
13587
|
*
|
|
13547
13588
|
* await db.user.join((q) => q.pets.none());
|
|
@@ -13791,7 +13832,8 @@ applyMixins(QueryMethods, [
|
|
|
13791
13832
|
SoftDeleteMethods,
|
|
13792
13833
|
QueryExpressions,
|
|
13793
13834
|
QueryWrap,
|
|
13794
|
-
QueryWindow
|
|
13835
|
+
QueryWindow,
|
|
13836
|
+
QueryExistsMethods
|
|
13795
13837
|
]);
|
|
13796
13838
|
const performQuery = async (q, args, method) => {
|
|
13797
13839
|
const trx = q.internal.asyncStorage.getStore();
|